@pnpm/exe 11.0.0-alpha.9 → 11.0.0-beta.1
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/node_modules/@gar/promise-retry/lib/index.js +28 -0
- package/dist/node_modules/@gar/promise-retry/package.json +48 -0
- package/dist/node_modules/@npmcli/agent/package.json +7 -7
- package/dist/node_modules/@npmcli/fs/package.json +4 -4
- package/dist/node_modules/abbrev/package.json +11 -15
- package/dist/node_modules/balanced-match/package.json +4 -7
- package/dist/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
- package/dist/node_modules/brace-expansion/dist/esm/index.js +1 -1
- package/dist/node_modules/brace-expansion/package.json +3 -3
- package/dist/node_modules/cacache/package.json +10 -11
- package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
- package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
- package/dist/node_modules/glob/dist/esm/glob.js +2 -1
- package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
- package/dist/node_modules/glob/package.json +38 -37
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
- package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
- package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
- package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
- package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
- package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
- package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/dist/node_modules/iconv-lite/lib/index.js +125 -123
- package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
- package/dist/node_modules/iconv-lite/package.json +34 -8
- package/dist/node_modules/isexe/package.json +65 -18
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/dist/node_modules/lru-cache/package.json +18 -41
- package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
- package/dist/node_modules/make-fetch-happen/package.json +10 -10
- package/dist/node_modules/minimatch/dist/commonjs/ast.js +266 -21
- package/dist/node_modules/minimatch/dist/commonjs/index.js +178 -92
- package/dist/node_modules/minimatch/dist/esm/ast.js +266 -21
- package/dist/node_modules/minimatch/dist/esm/index.js +178 -92
- package/dist/node_modules/minimatch/package.json +4 -4
- package/dist/node_modules/minipass/dist/commonjs/index.js +13 -3
- package/dist/node_modules/minipass/dist/esm/index.js +3 -1
- package/dist/node_modules/minipass/package.json +9 -14
- package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
- package/dist/node_modules/minipass-fetch/package.json +7 -7
- package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
- package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
- package/dist/node_modules/minipass-sized/package.json +39 -9
- package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
- package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
- package/dist/node_modules/node-gyp/lib/build.js +2 -2
- package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
- package/dist/node_modules/node-gyp/lib/install.js +1 -1
- package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
- package/dist/node_modules/node-gyp/package.json +13 -13
- package/dist/node_modules/nopt/package.json +5 -5
- package/dist/node_modules/path-scurry/package.json +8 -24
- package/dist/node_modules/proc-log/lib/index.js +10 -5
- package/dist/node_modules/proc-log/package.json +5 -5
- package/dist/node_modules/retry/lib/retry.js +2 -2
- package/dist/node_modules/retry/lib/retry_operation.js +10 -6
- package/dist/node_modules/retry/package.json +6 -2
- package/dist/node_modules/ssri/lib/index.js +33 -63
- package/dist/node_modules/ssri/package.json +17 -17
- package/dist/node_modules/tar/dist/commonjs/index.min.js +2 -2
- package/dist/node_modules/tar/dist/commonjs/unpack.js +4 -4
- package/dist/node_modules/tar/dist/esm/index.min.js +2 -2
- package/dist/node_modules/tar/dist/esm/unpack.js +4 -4
- package/dist/node_modules/tar/package.json +6 -6
- package/dist/node_modules/unique-filename/package.json +5 -5
- package/dist/node_modules/unique-slug/package.json +4 -4
- package/dist/node_modules/which/package.json +29 -20
- package/dist/pnpm.mjs +225713 -208017
- package/dist/worker.js +4838 -5926
- package/package.json +10 -10
- package/setup.js +12 -14
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
- package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
- package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
- package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
- package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
- package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
- package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
- package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
- package/dist/node_modules/@isaacs/cliui/package.json +0 -163
- package/dist/node_modules/cross-spawn/LICENSE +0 -21
- package/dist/node_modules/cross-spawn/index.js +0 -39
- package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
- package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
- package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
- package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
- package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
- package/dist/node_modules/cross-spawn/package.json +0 -73
- package/dist/node_modules/encoding/.prettierrc.js +0 -8
- package/dist/node_modules/encoding/LICENSE +0 -16
- package/dist/node_modules/encoding/lib/encoding.js +0 -83
- package/dist/node_modules/encoding/package.json +0 -18
- package/dist/node_modules/err-code/.eslintrc.json +0 -7
- package/dist/node_modules/err-code/bower.json +0 -30
- package/dist/node_modules/err-code/index.js +0 -47
- package/dist/node_modules/err-code/index.umd.js +0 -51
- package/dist/node_modules/err-code/package.json +0 -34
- package/dist/node_modules/foreground-child/LICENSE +0 -15
- package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
- package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
- package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
- package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
- package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
- package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
- package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
- package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
- package/dist/node_modules/foreground-child/package.json +0 -106
- package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
- package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
- package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
- package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
- package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
- package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
- package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
- package/dist/node_modules/isexe/LICENSE +0 -15
- package/dist/node_modules/isexe/index.js +0 -57
- package/dist/node_modules/isexe/mode.js +0 -41
- package/dist/node_modules/isexe/windows.js +0 -42
- package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
- package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
- package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
- package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
- package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
- package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
- package/dist/node_modules/jackspeak/package.json +0 -115
- package/dist/node_modules/lru-cache/LICENSE +0 -15
- package/dist/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-sized/index.js +0 -67
- package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
- package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
- package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
- package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
- package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
- package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
- package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
- package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
- package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
- package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
- package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
- package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
- package/dist/node_modules/package-json-from-dist/package.json +0 -68
- package/dist/node_modules/path-key/index.js +0 -16
- package/dist/node_modules/path-key/license +0 -9
- package/dist/node_modules/path-key/package.json +0 -39
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
- package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
- package/dist/node_modules/promise-retry/index.js +0 -52
- package/dist/node_modules/promise-retry/package.json +0 -37
- package/dist/node_modules/retry/equation.gif +0 -0
- package/dist/node_modules/shebang-command/index.js +0 -19
- package/dist/node_modules/shebang-command/license +0 -9
- package/dist/node_modules/shebang-command/package.json +0 -34
- package/dist/node_modules/shebang-regex/index.js +0 -2
- package/dist/node_modules/shebang-regex/license +0 -9
- package/dist/node_modules/shebang-regex/package.json +0 -35
- package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
- package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
- package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
- package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
- package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
- package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
- package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
- package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
- package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
- package/dist/node_modules/signal-exit/package.json +0 -106
- package/dist/node_modules/which/bin/node-which +0 -52
- package/dist/node_modules/which/which.js +0 -125
- /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
- /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
- /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
- /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
- /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
|
@@ -1,198 +1,218 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var Buffer = require("safer-buffer").Buffer
|
|
1
|
+
"use strict"
|
|
2
|
+
var Buffer = require("safer-buffer").Buffer
|
|
3
3
|
|
|
4
4
|
// Export Node.js internal encodings.
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ucs2: { type: "_internal", bomAware: true},
|
|
13
|
-
utf16le: "ucs2",
|
|
14
|
-
|
|
15
|
-
binary: { type: "_internal" },
|
|
16
|
-
base64: { type: "_internal" },
|
|
17
|
-
hex: { type: "_internal" },
|
|
18
|
-
|
|
19
|
-
// Codec.
|
|
20
|
-
_internal: InternalCodec,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//------------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
function InternalCodec(codecOptions, iconv) {
|
|
26
|
-
this.enc = codecOptions.encodingName;
|
|
27
|
-
this.bomAware = codecOptions.bomAware;
|
|
28
|
-
|
|
29
|
-
if (this.enc === "base64")
|
|
30
|
-
this.encoder = InternalEncoderBase64;
|
|
31
|
-
else if (this.enc === "cesu8") {
|
|
32
|
-
this.enc = "utf8"; // Use utf8 for decoding.
|
|
33
|
-
this.encoder = InternalEncoderCesu8;
|
|
34
|
-
|
|
35
|
-
// Add decoder for versions of Node not supporting CESU-8
|
|
36
|
-
if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') {
|
|
37
|
-
this.decoder = InternalDecoderCesu8;
|
|
38
|
-
this.defaultCharUnicode = iconv.defaultCharUnicode;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
7
|
+
// Encodings
|
|
8
|
+
utf8: { type: "_internal", bomAware: true },
|
|
9
|
+
cesu8: { type: "_internal", bomAware: true },
|
|
10
|
+
unicode11utf8: "utf8",
|
|
42
11
|
|
|
43
|
-
|
|
44
|
-
|
|
12
|
+
ucs2: { type: "_internal", bomAware: true },
|
|
13
|
+
utf16le: "ucs2",
|
|
45
14
|
|
|
46
|
-
|
|
15
|
+
binary: { type: "_internal" },
|
|
16
|
+
base64: { type: "_internal" },
|
|
17
|
+
hex: { type: "_internal" },
|
|
47
18
|
|
|
48
|
-
//
|
|
49
|
-
|
|
19
|
+
// Codec.
|
|
20
|
+
_internal: InternalCodec
|
|
21
|
+
}
|
|
50
22
|
|
|
51
|
-
|
|
52
|
-
StringDecoder.prototype.end = function() {};
|
|
23
|
+
// ------------------------------------------------------------------------------
|
|
53
24
|
|
|
25
|
+
function InternalCodec (codecOptions, iconv) {
|
|
26
|
+
this.enc = codecOptions.encodingName
|
|
27
|
+
this.bomAware = codecOptions.bomAware
|
|
54
28
|
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
29
|
+
if (this.enc === "base64") { this.encoder = InternalEncoderBase64 } else if (this.enc === "utf8") { this.encoder = InternalEncoderUtf8 } else if (this.enc === "cesu8") {
|
|
30
|
+
this.enc = "utf8" // Use utf8 for decoding.
|
|
31
|
+
this.encoder = InternalEncoderCesu8
|
|
58
32
|
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
33
|
+
// Add decoder for versions of Node not supporting CESU-8
|
|
34
|
+
if (Buffer.from("eda0bdedb2a9", "hex").toString() !== "💩") {
|
|
35
|
+
this.decoder = InternalDecoderCesu8
|
|
36
|
+
this.defaultCharUnicode = iconv.defaultCharUnicode
|
|
62
37
|
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
63
40
|
|
|
64
|
-
|
|
41
|
+
InternalCodec.prototype.encoder = InternalEncoder
|
|
42
|
+
InternalCodec.prototype.decoder = InternalDecoder
|
|
43
|
+
|
|
44
|
+
// ------------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
// We use node.js internal decoder. Its signature is the same as ours.
|
|
47
|
+
var StringDecoder = require("string_decoder").StringDecoder
|
|
48
|
+
|
|
49
|
+
function InternalDecoder (options, codec) {
|
|
50
|
+
this.decoder = new StringDecoder(codec.enc)
|
|
65
51
|
}
|
|
66
52
|
|
|
67
|
-
InternalDecoder.prototype.
|
|
68
|
-
|
|
53
|
+
InternalDecoder.prototype.write = function (buf) {
|
|
54
|
+
if (!Buffer.isBuffer(buf)) {
|
|
55
|
+
buf = Buffer.from(buf)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this.decoder.write(buf)
|
|
69
59
|
}
|
|
70
60
|
|
|
61
|
+
InternalDecoder.prototype.end = function () {
|
|
62
|
+
return this.decoder.end()
|
|
63
|
+
}
|
|
71
64
|
|
|
72
|
-
|
|
65
|
+
// ------------------------------------------------------------------------------
|
|
73
66
|
// Encoder is mostly trivial
|
|
74
67
|
|
|
75
|
-
function InternalEncoder(options, codec) {
|
|
76
|
-
|
|
68
|
+
function InternalEncoder (options, codec) {
|
|
69
|
+
this.enc = codec.enc
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
InternalEncoder.prototype.write = function(str) {
|
|
80
|
-
|
|
72
|
+
InternalEncoder.prototype.write = function (str) {
|
|
73
|
+
return Buffer.from(str, this.enc)
|
|
81
74
|
}
|
|
82
75
|
|
|
83
|
-
InternalEncoder.prototype.end = function() {
|
|
76
|
+
InternalEncoder.prototype.end = function () {
|
|
84
77
|
}
|
|
85
78
|
|
|
86
|
-
|
|
87
|
-
//------------------------------------------------------------------------------
|
|
79
|
+
// ------------------------------------------------------------------------------
|
|
88
80
|
// Except base64 encoder, which must keep its state.
|
|
89
81
|
|
|
90
|
-
function InternalEncoderBase64(options, codec) {
|
|
91
|
-
|
|
82
|
+
function InternalEncoderBase64 (options, codec) {
|
|
83
|
+
this.prevStr = ""
|
|
92
84
|
}
|
|
93
85
|
|
|
94
|
-
InternalEncoderBase64.prototype.write = function(str) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
InternalEncoderBase64.prototype.write = function (str) {
|
|
87
|
+
str = this.prevStr + str
|
|
88
|
+
var completeQuads = str.length - (str.length % 4)
|
|
89
|
+
this.prevStr = str.slice(completeQuads)
|
|
90
|
+
str = str.slice(0, completeQuads)
|
|
99
91
|
|
|
100
|
-
|
|
92
|
+
return Buffer.from(str, "base64")
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
InternalEncoderBase64.prototype.end = function() {
|
|
104
|
-
|
|
95
|
+
InternalEncoderBase64.prototype.end = function () {
|
|
96
|
+
return Buffer.from(this.prevStr, "base64")
|
|
105
97
|
}
|
|
106
98
|
|
|
107
|
-
|
|
108
|
-
//------------------------------------------------------------------------------
|
|
99
|
+
// ------------------------------------------------------------------------------
|
|
109
100
|
// CESU-8 encoder is also special.
|
|
110
101
|
|
|
111
|
-
function InternalEncoderCesu8(options, codec) {
|
|
102
|
+
function InternalEncoderCesu8 (options, codec) {
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
InternalEncoderCesu8.prototype.write = function (str) {
|
|
106
|
+
var buf = Buffer.alloc(str.length * 3); var bufIdx = 0
|
|
107
|
+
for (var i = 0; i < str.length; i++) {
|
|
108
|
+
var charCode = str.charCodeAt(i)
|
|
109
|
+
// Naive implementation, but it works because CESU-8 is especially easy
|
|
110
|
+
// to convert from UTF-16 (which all JS strings are encoded in).
|
|
111
|
+
if (charCode < 0x80) { buf[bufIdx++] = charCode } else if (charCode < 0x800) {
|
|
112
|
+
buf[bufIdx++] = 0xC0 + (charCode >>> 6)
|
|
113
|
+
buf[bufIdx++] = 0x80 + (charCode & 0x3f)
|
|
114
|
+
} else { // charCode will always be < 0x10000 in javascript.
|
|
115
|
+
buf[bufIdx++] = 0xE0 + (charCode >>> 12)
|
|
116
|
+
buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f)
|
|
117
|
+
buf[bufIdx++] = 0x80 + (charCode & 0x3f)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return buf.slice(0, bufIdx)
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
InternalEncoderCesu8.prototype.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
InternalEncoderCesu8.prototype.end = function () {
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ------------------------------------------------------------------------------
|
|
127
|
+
// CESU-8 decoder is not implemented in Node v4.0+
|
|
128
|
+
|
|
129
|
+
function InternalDecoderCesu8 (options, codec) {
|
|
130
|
+
this.acc = 0
|
|
131
|
+
this.contBytes = 0
|
|
132
|
+
this.accBytes = 0
|
|
133
|
+
this.defaultCharUnicode = codec.defaultCharUnicode
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
InternalDecoderCesu8.prototype.write = function (buf) {
|
|
137
|
+
var acc = this.acc; var contBytes = this.contBytes; var accBytes = this.accBytes
|
|
138
|
+
var res = ""
|
|
139
|
+
for (var i = 0; i < buf.length; i++) {
|
|
140
|
+
var curByte = buf[i]
|
|
141
|
+
if ((curByte & 0xC0) !== 0x80) { // Leading byte
|
|
142
|
+
if (contBytes > 0) { // Previous code is invalid
|
|
143
|
+
res += this.defaultCharUnicode
|
|
144
|
+
contBytes = 0
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (curByte < 0x80) { // Single-byte code
|
|
148
|
+
res += String.fromCharCode(curByte)
|
|
149
|
+
} else if (curByte < 0xE0) { // Two-byte code
|
|
150
|
+
acc = curByte & 0x1F
|
|
151
|
+
contBytes = 1; accBytes = 1
|
|
152
|
+
} else if (curByte < 0xF0) { // Three-byte code
|
|
153
|
+
acc = curByte & 0x0F
|
|
154
|
+
contBytes = 2; accBytes = 1
|
|
155
|
+
} else { // Four or more are not supported for CESU-8.
|
|
156
|
+
res += this.defaultCharUnicode
|
|
157
|
+
}
|
|
158
|
+
} else { // Continuation byte
|
|
159
|
+
if (contBytes > 0) { // We're waiting for it.
|
|
160
|
+
acc = (acc << 6) | (curByte & 0x3f)
|
|
161
|
+
contBytes--; accBytes++
|
|
162
|
+
if (contBytes === 0) {
|
|
163
|
+
// Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)
|
|
164
|
+
if (accBytes === 2 && acc < 0x80 && acc > 0) {
|
|
165
|
+
res += this.defaultCharUnicode
|
|
166
|
+
} else if (accBytes === 3 && acc < 0x800) {
|
|
167
|
+
res += this.defaultCharUnicode
|
|
168
|
+
} else {
|
|
169
|
+
// Actually add character.
|
|
170
|
+
res += String.fromCharCode(acc)
|
|
171
|
+
}
|
|
130
172
|
}
|
|
173
|
+
} else { // Unexpected continuation byte
|
|
174
|
+
res += this.defaultCharUnicode
|
|
175
|
+
}
|
|
131
176
|
}
|
|
132
|
-
|
|
177
|
+
}
|
|
178
|
+
this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes
|
|
179
|
+
return res
|
|
133
180
|
}
|
|
134
181
|
|
|
135
|
-
|
|
182
|
+
InternalDecoderCesu8.prototype.end = function () {
|
|
183
|
+
var res = 0
|
|
184
|
+
if (this.contBytes > 0) { res += this.defaultCharUnicode }
|
|
185
|
+
return res
|
|
136
186
|
}
|
|
137
187
|
|
|
138
|
-
|
|
139
|
-
//
|
|
188
|
+
// ------------------------------------------------------------------------------
|
|
189
|
+
// check the chunk boundaries for surrogate pair
|
|
140
190
|
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
contBytes = 0;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (curByte < 0x80) { // Single-byte code
|
|
160
|
-
res += String.fromCharCode(curByte);
|
|
161
|
-
} else if (curByte < 0xE0) { // Two-byte code
|
|
162
|
-
acc = curByte & 0x1F;
|
|
163
|
-
contBytes = 1; accBytes = 1;
|
|
164
|
-
} else if (curByte < 0xF0) { // Three-byte code
|
|
165
|
-
acc = curByte & 0x0F;
|
|
166
|
-
contBytes = 2; accBytes = 1;
|
|
167
|
-
} else { // Four or more are not supported for CESU-8.
|
|
168
|
-
res += this.defaultCharUnicode;
|
|
169
|
-
}
|
|
170
|
-
} else { // Continuation byte
|
|
171
|
-
if (contBytes > 0) { // We're waiting for it.
|
|
172
|
-
acc = (acc << 6) | (curByte & 0x3f);
|
|
173
|
-
contBytes--; accBytes++;
|
|
174
|
-
if (contBytes === 0) {
|
|
175
|
-
// Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80)
|
|
176
|
-
if (accBytes === 2 && acc < 0x80 && acc > 0)
|
|
177
|
-
res += this.defaultCharUnicode;
|
|
178
|
-
else if (accBytes === 3 && acc < 0x800)
|
|
179
|
-
res += this.defaultCharUnicode;
|
|
180
|
-
else
|
|
181
|
-
// Actually add character.
|
|
182
|
-
res += String.fromCharCode(acc);
|
|
183
|
-
}
|
|
184
|
-
} else { // Unexpected continuation byte
|
|
185
|
-
res += this.defaultCharUnicode;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
191
|
+
function InternalEncoderUtf8 (options, codec) {
|
|
192
|
+
this.highSurrogate = ""
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
InternalEncoderUtf8.prototype.write = function (str) {
|
|
196
|
+
if (this.highSurrogate) {
|
|
197
|
+
str = this.highSurrogate + str
|
|
198
|
+
this.highSurrogate = ""
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (str.length > 0) {
|
|
202
|
+
var charCode = str.charCodeAt(str.length - 1)
|
|
203
|
+
if (charCode >= 0xd800 && charCode < 0xdc00) {
|
|
204
|
+
this.highSurrogate = str[str.length - 1]
|
|
205
|
+
str = str.slice(0, str.length - 1)
|
|
188
206
|
}
|
|
189
|
-
|
|
190
|
-
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return Buffer.from(str, this.enc)
|
|
191
210
|
}
|
|
192
211
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return
|
|
212
|
+
InternalEncoderUtf8.prototype.end = function () {
|
|
213
|
+
if (this.highSurrogate) {
|
|
214
|
+
var str = this.highSurrogate
|
|
215
|
+
this.highSurrogate = ""
|
|
216
|
+
return Buffer.from(str, this.enc)
|
|
217
|
+
}
|
|
198
218
|
}
|
|
@@ -1,72 +1,75 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
var Buffer = require("safer-buffer").Buffer
|
|
1
|
+
"use strict"
|
|
2
|
+
var Buffer = require("safer-buffer").Buffer
|
|
3
3
|
|
|
4
4
|
// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that
|
|
5
|
-
// correspond to encoded bytes (if 128 - then lower half is ASCII).
|
|
6
|
-
|
|
7
|
-
exports._sbcs = SBCSCodec;
|
|
8
|
-
function SBCSCodec(codecOptions, iconv) {
|
|
9
|
-
if (!codecOptions)
|
|
10
|
-
throw new Error("SBCS codec is called without the data.")
|
|
11
|
-
|
|
12
|
-
// Prepare char buffer for decoding.
|
|
13
|
-
if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256))
|
|
14
|
-
throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)");
|
|
15
|
-
|
|
16
|
-
if (codecOptions.chars.length === 128) {
|
|
17
|
-
var asciiString = "";
|
|
18
|
-
for (var i = 0; i < 128; i++)
|
|
19
|
-
asciiString += String.fromCharCode(i);
|
|
20
|
-
codecOptions.chars = asciiString + codecOptions.chars;
|
|
21
|
-
}
|
|
5
|
+
// correspond to encoded bytes (if 128 - then lower half is ASCII).
|
|
22
6
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
exports._sbcs = SBCSCodec
|
|
8
|
+
function SBCSCodec (codecOptions, iconv) {
|
|
9
|
+
if (!codecOptions) {
|
|
10
|
+
throw new Error("SBCS codec is called without the data.")
|
|
11
|
+
}
|
|
27
12
|
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
// Prepare char buffer for decoding.
|
|
14
|
+
if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)) {
|
|
15
|
+
throw new Error("Encoding '" + codecOptions.type + "' has incorrect 'chars' (must be of len 128 or 256)")
|
|
16
|
+
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
if (codecOptions.chars.length === 128) {
|
|
19
|
+
var asciiString = ""
|
|
20
|
+
for (var i = 0; i < 128; i++) {
|
|
21
|
+
asciiString += String.fromCharCode(i)
|
|
22
|
+
}
|
|
23
|
+
codecOptions.chars = asciiString + codecOptions.chars
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.decodeBuf = Buffer.from(codecOptions.chars, "ucs2")
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
// Encoding buffer.
|
|
29
|
+
var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0))
|
|
36
30
|
|
|
31
|
+
for (var i = 0; i < codecOptions.chars.length; i++) {
|
|
32
|
+
encodeBuf[codecOptions.chars.charCodeAt(i)] = i
|
|
33
|
+
}
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
this.encodeBuf = codec.encodeBuf;
|
|
35
|
+
this.encodeBuf = encodeBuf
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return buf;
|
|
38
|
+
SBCSCodec.prototype.encoder = SBCSEncoder
|
|
39
|
+
SBCSCodec.prototype.decoder = SBCSDecoder
|
|
40
|
+
|
|
41
|
+
function SBCSEncoder (options, codec) {
|
|
42
|
+
this.encodeBuf = codec.encodeBuf
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
SBCSEncoder.prototype.
|
|
45
|
+
SBCSEncoder.prototype.write = function (str) {
|
|
46
|
+
var buf = Buffer.alloc(str.length)
|
|
47
|
+
for (var i = 0; i < str.length; i++) {
|
|
48
|
+
buf[i] = this.encodeBuf[str.charCodeAt(i)]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return buf
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
SBCSEncoder.prototype.end = function () {
|
|
55
|
+
}
|
|
53
56
|
|
|
54
|
-
function SBCSDecoder(options, codec) {
|
|
55
|
-
|
|
57
|
+
function SBCSDecoder (options, codec) {
|
|
58
|
+
this.decodeBuf = codec.decodeBuf
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
SBCSDecoder.prototype.write = function(buf) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
SBCSDecoder.prototype.write = function (buf) {
|
|
62
|
+
// Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
|
|
63
|
+
var decodeBuf = this.decodeBuf
|
|
64
|
+
var newBuf = Buffer.alloc(buf.length * 2)
|
|
65
|
+
var idx1 = 0; var idx2 = 0
|
|
66
|
+
for (var i = 0; i < buf.length; i++) {
|
|
67
|
+
idx1 = buf[i] * 2; idx2 = i * 2
|
|
68
|
+
newBuf[idx2] = decodeBuf[idx1]
|
|
69
|
+
newBuf[idx2 + 1] = decodeBuf[idx1 + 1]
|
|
70
|
+
}
|
|
71
|
+
return newBuf.toString("ucs2")
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
SBCSDecoder.prototype.end = function() {
|
|
74
|
+
SBCSDecoder.prototype.end = function () {
|
|
72
75
|
}
|