@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,186 +1,176 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict"
|
|
2
2
|
|
|
3
|
-
var Buffer = require(
|
|
3
|
+
var Buffer = require("safer-buffer").Buffer
|
|
4
4
|
|
|
5
5
|
// == UTF32-LE/BE codec. ==========================================================
|
|
6
6
|
|
|
7
|
-
exports._utf32 = Utf32Codec
|
|
7
|
+
exports._utf32 = Utf32Codec
|
|
8
8
|
|
|
9
|
-
function Utf32Codec(codecOptions, iconv) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
function Utf32Codec (codecOptions, iconv) {
|
|
10
|
+
this.iconv = iconv
|
|
11
|
+
this.bomAware = true
|
|
12
|
+
this.isLE = codecOptions.isLE
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
exports.utf32le = { type:
|
|
16
|
-
exports.utf32be = { type:
|
|
15
|
+
exports.utf32le = { type: "_utf32", isLE: true }
|
|
16
|
+
exports.utf32be = { type: "_utf32", isLE: false }
|
|
17
17
|
|
|
18
18
|
// Aliases
|
|
19
|
-
exports.ucs4le =
|
|
20
|
-
exports.ucs4be =
|
|
19
|
+
exports.ucs4le = "utf32le"
|
|
20
|
+
exports.ucs4be = "utf32be"
|
|
21
21
|
|
|
22
|
-
Utf32Codec.prototype.encoder = Utf32Encoder
|
|
23
|
-
Utf32Codec.prototype.decoder = Utf32Decoder
|
|
22
|
+
Utf32Codec.prototype.encoder = Utf32Encoder
|
|
23
|
+
Utf32Codec.prototype.decoder = Utf32Decoder
|
|
24
24
|
|
|
25
25
|
// -- Encoding
|
|
26
26
|
|
|
27
|
-
function Utf32Encoder(options, codec) {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function Utf32Encoder (options, codec) {
|
|
28
|
+
this.isLE = codec.isLE
|
|
29
|
+
this.highSurrogate = 0
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
Utf32Encoder.prototype.write = function(str) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
32
|
+
Utf32Encoder.prototype.write = function (str) {
|
|
33
|
+
var src = Buffer.from(str, "ucs2")
|
|
34
|
+
var dst = Buffer.alloc(src.length * 2)
|
|
35
|
+
var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE
|
|
36
|
+
var offset = 0
|
|
37
|
+
|
|
38
|
+
for (var i = 0; i < src.length; i += 2) {
|
|
39
|
+
var code = src.readUInt16LE(i)
|
|
40
|
+
var isHighSurrogate = (code >= 0xD800 && code < 0xDC00)
|
|
41
|
+
var isLowSurrogate = (code >= 0xDC00 && code < 0xE000)
|
|
42
|
+
|
|
43
|
+
if (this.highSurrogate) {
|
|
44
|
+
if (isHighSurrogate || !isLowSurrogate) {
|
|
45
|
+
// There shouldn't be two high surrogates in a row, nor a high surrogate which isn't followed by a low
|
|
46
|
+
// surrogate. If this happens, keep the pending high surrogate as a stand-alone semi-invalid character
|
|
47
|
+
// (technically wrong, but expected by some applications, like Windows file names).
|
|
48
|
+
write32.call(dst, this.highSurrogate, offset)
|
|
49
|
+
offset += 4
|
|
50
|
+
} else {
|
|
51
|
+
// Create 32-bit value from high and low surrogates;
|
|
52
|
+
var codepoint = (((this.highSurrogate - 0xD800) << 10) | (code - 0xDC00)) + 0x10000
|
|
53
|
+
|
|
54
|
+
write32.call(dst, codepoint, offset)
|
|
55
|
+
offset += 4
|
|
56
|
+
this.highSurrogate = 0
|
|
57
|
+
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
offset += 4;
|
|
71
|
-
this.highSurrogate = 0;
|
|
72
|
-
}
|
|
62
|
+
if (isHighSurrogate) { this.highSurrogate = code } else {
|
|
63
|
+
// Even if the current character is a low surrogate, with no previous high surrogate, we'll
|
|
64
|
+
// encode it as a semi-invalid stand-alone character for the same reasons expressed above for
|
|
65
|
+
// unpaired high surrogates.
|
|
66
|
+
write32.call(dst, code, offset)
|
|
67
|
+
offset += 4
|
|
68
|
+
this.highSurrogate = 0
|
|
73
69
|
}
|
|
70
|
+
}
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
dst = dst.slice(0, offset);
|
|
72
|
+
if (offset < dst.length) { dst = dst.slice(0, offset) }
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
}
|
|
74
|
+
return dst
|
|
75
|
+
}
|
|
80
76
|
|
|
81
|
-
Utf32Encoder.prototype.end = function() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return;
|
|
77
|
+
Utf32Encoder.prototype.end = function () {
|
|
78
|
+
// Treat any leftover high surrogate as a semi-valid independent character.
|
|
79
|
+
if (!this.highSurrogate) { return }
|
|
85
80
|
|
|
86
|
-
|
|
81
|
+
var buf = Buffer.alloc(4)
|
|
87
82
|
|
|
88
|
-
|
|
89
|
-
buf.writeUInt32LE(this.highSurrogate, 0);
|
|
90
|
-
else
|
|
91
|
-
buf.writeUInt32BE(this.highSurrogate, 0);
|
|
83
|
+
if (this.isLE) { buf.writeUInt32LE(this.highSurrogate, 0) } else { buf.writeUInt32BE(this.highSurrogate, 0) }
|
|
92
84
|
|
|
93
|
-
|
|
85
|
+
this.highSurrogate = 0
|
|
94
86
|
|
|
95
|
-
|
|
96
|
-
}
|
|
87
|
+
return buf
|
|
88
|
+
}
|
|
97
89
|
|
|
98
90
|
// -- Decoding
|
|
99
91
|
|
|
100
|
-
function Utf32Decoder(options, codec) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
function Utf32Decoder (options, codec) {
|
|
93
|
+
this.isLE = codec.isLE
|
|
94
|
+
this.badChar = codec.iconv.defaultCharUnicode.charCodeAt(0)
|
|
95
|
+
this.overflow = []
|
|
104
96
|
}
|
|
105
97
|
|
|
106
|
-
Utf32Decoder.prototype.write = function(src) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
offset = _writeCodepoint(dst, offset, codepoint, badChar);
|
|
133
|
-
}
|
|
98
|
+
Utf32Decoder.prototype.write = function (src) {
|
|
99
|
+
if (src.length === 0) { return "" }
|
|
100
|
+
|
|
101
|
+
var i = 0
|
|
102
|
+
var codepoint = 0
|
|
103
|
+
var dst = Buffer.alloc(src.length + 4)
|
|
104
|
+
var offset = 0
|
|
105
|
+
var isLE = this.isLE
|
|
106
|
+
var overflow = this.overflow
|
|
107
|
+
var badChar = this.badChar
|
|
108
|
+
|
|
109
|
+
if (overflow.length > 0) {
|
|
110
|
+
for (; i < src.length && overflow.length < 4; i++) { overflow.push(src[i]) }
|
|
111
|
+
|
|
112
|
+
if (overflow.length === 4) {
|
|
113
|
+
// NOTE: codepoint is a signed int32 and can be negative.
|
|
114
|
+
// NOTE: We copied this block from below to help V8 optimize it (it works with array, not buffer).
|
|
115
|
+
if (isLE) {
|
|
116
|
+
codepoint = overflow[i] | (overflow[i + 1] << 8) | (overflow[i + 2] << 16) | (overflow[i + 3] << 24)
|
|
117
|
+
} else {
|
|
118
|
+
codepoint = overflow[i + 3] | (overflow[i + 2] << 8) | (overflow[i + 1] << 16) | (overflow[i] << 24)
|
|
119
|
+
}
|
|
120
|
+
overflow.length = 0
|
|
121
|
+
|
|
122
|
+
offset = _writeCodepoint(dst, offset, codepoint, badChar)
|
|
134
123
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
offset = _writeCodepoint(dst, offset, codepoint, badChar);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Main loop. Should be as optimized as possible.
|
|
127
|
+
for (; i < src.length - 3; i += 4) {
|
|
128
|
+
// NOTE: codepoint is a signed int32 and can be negative.
|
|
129
|
+
if (isLE) {
|
|
130
|
+
codepoint = src[i] | (src[i + 1] << 8) | (src[i + 2] << 16) | (src[i + 3] << 24)
|
|
131
|
+
} else {
|
|
132
|
+
codepoint = src[i + 3] | (src[i + 2] << 8) | (src[i + 1] << 16) | (src[i] << 24)
|
|
145
133
|
}
|
|
134
|
+
offset = _writeCodepoint(dst, offset, codepoint, badChar)
|
|
135
|
+
}
|
|
146
136
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
// Keep overflowing bytes.
|
|
138
|
+
for (; i < src.length; i++) {
|
|
139
|
+
overflow.push(src[i])
|
|
140
|
+
}
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
}
|
|
142
|
+
return dst.slice(0, offset).toString("ucs2")
|
|
143
|
+
}
|
|
154
144
|
|
|
155
|
-
function _writeCodepoint(dst, offset, codepoint, badChar) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
function _writeCodepoint (dst, offset, codepoint, badChar) {
|
|
146
|
+
// NOTE: codepoint is signed int32 and can be negative. We keep it that way to help V8 with optimizations.
|
|
147
|
+
if (codepoint < 0 || codepoint > 0x10FFFF) {
|
|
148
|
+
// Not a valid Unicode codepoint
|
|
149
|
+
codepoint = badChar
|
|
150
|
+
}
|
|
161
151
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
// Ephemeral Planes: Write high surrogate.
|
|
153
|
+
if (codepoint >= 0x10000) {
|
|
154
|
+
codepoint -= 0x10000
|
|
165
155
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
156
|
+
var high = 0xD800 | (codepoint >> 10)
|
|
157
|
+
dst[offset++] = high & 0xff
|
|
158
|
+
dst[offset++] = high >> 8
|
|
169
159
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
160
|
+
// Low surrogate is written below.
|
|
161
|
+
var codepoint = 0xDC00 | (codepoint & 0x3FF)
|
|
162
|
+
}
|
|
173
163
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
164
|
+
// Write BMP char or low surrogate.
|
|
165
|
+
dst[offset++] = codepoint & 0xff
|
|
166
|
+
dst[offset++] = codepoint >> 8
|
|
177
167
|
|
|
178
|
-
|
|
168
|
+
return offset
|
|
179
169
|
};
|
|
180
170
|
|
|
181
|
-
Utf32Decoder.prototype.end = function() {
|
|
182
|
-
|
|
183
|
-
}
|
|
171
|
+
Utf32Decoder.prototype.end = function () {
|
|
172
|
+
this.overflow.length = 0
|
|
173
|
+
}
|
|
184
174
|
|
|
185
175
|
// == UTF-32 Auto codec =============================================================
|
|
186
176
|
// Decoder chooses automatically from UTF-32LE and UTF-32BE using BOM and space-based heuristic.
|
|
@@ -189,131 +179,129 @@ Utf32Decoder.prototype.end = function() {
|
|
|
189
179
|
|
|
190
180
|
// Encoder prepends BOM (which can be overridden with (addBOM: false}).
|
|
191
181
|
|
|
192
|
-
exports.utf32 = Utf32AutoCodec
|
|
193
|
-
exports.ucs4 =
|
|
182
|
+
exports.utf32 = Utf32AutoCodec
|
|
183
|
+
exports.ucs4 = "utf32"
|
|
194
184
|
|
|
195
|
-
function Utf32AutoCodec(options, iconv) {
|
|
196
|
-
|
|
185
|
+
function Utf32AutoCodec (options, iconv) {
|
|
186
|
+
this.iconv = iconv
|
|
197
187
|
}
|
|
198
188
|
|
|
199
|
-
Utf32AutoCodec.prototype.encoder = Utf32AutoEncoder
|
|
200
|
-
Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder
|
|
189
|
+
Utf32AutoCodec.prototype.encoder = Utf32AutoEncoder
|
|
190
|
+
Utf32AutoCodec.prototype.decoder = Utf32AutoDecoder
|
|
201
191
|
|
|
202
192
|
// -- Encoding
|
|
203
193
|
|
|
204
|
-
function Utf32AutoEncoder(options, codec) {
|
|
205
|
-
|
|
194
|
+
function Utf32AutoEncoder (options, codec) {
|
|
195
|
+
options = options || {}
|
|
206
196
|
|
|
207
|
-
|
|
208
|
-
|
|
197
|
+
if (options.addBOM === undefined) {
|
|
198
|
+
options.addBOM = true
|
|
199
|
+
}
|
|
209
200
|
|
|
210
|
-
|
|
201
|
+
this.encoder = codec.iconv.getEncoder(options.defaultEncoding || "utf-32le", options)
|
|
211
202
|
}
|
|
212
203
|
|
|
213
|
-
Utf32AutoEncoder.prototype.write = function(str) {
|
|
214
|
-
|
|
215
|
-
}
|
|
204
|
+
Utf32AutoEncoder.prototype.write = function (str) {
|
|
205
|
+
return this.encoder.write(str)
|
|
206
|
+
}
|
|
216
207
|
|
|
217
|
-
Utf32AutoEncoder.prototype.end = function() {
|
|
218
|
-
|
|
219
|
-
}
|
|
208
|
+
Utf32AutoEncoder.prototype.end = function () {
|
|
209
|
+
return this.encoder.end()
|
|
210
|
+
}
|
|
220
211
|
|
|
221
212
|
// -- Decoding
|
|
222
213
|
|
|
223
|
-
function Utf32AutoDecoder(options, codec) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
214
|
+
function Utf32AutoDecoder (options, codec) {
|
|
215
|
+
this.decoder = null
|
|
216
|
+
this.initialBufs = []
|
|
217
|
+
this.initialBufsLen = 0
|
|
218
|
+
this.options = options || {}
|
|
219
|
+
this.iconv = codec.iconv
|
|
229
220
|
}
|
|
230
221
|
|
|
231
|
-
Utf32AutoDecoder.prototype.write = function(buf) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
222
|
+
Utf32AutoDecoder.prototype.write = function (buf) {
|
|
223
|
+
if (!this.decoder) {
|
|
224
|
+
// Codec is not chosen yet. Accumulate initial bytes.
|
|
225
|
+
this.initialBufs.push(buf)
|
|
226
|
+
this.initialBufsLen += buf.length
|
|
236
227
|
|
|
237
|
-
|
|
238
|
-
|
|
228
|
+
if (this.initialBufsLen < 32) // We need more bytes to use space heuristic (see below)
|
|
229
|
+
{ return "" }
|
|
239
230
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
231
|
+
// We have enough bytes -> detect endianness.
|
|
232
|
+
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding)
|
|
233
|
+
this.decoder = this.iconv.getDecoder(encoding, this.options)
|
|
243
234
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
resStr += this.decoder.write(this.initialBufs[i]);
|
|
235
|
+
var resStr = ""
|
|
236
|
+
for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) }
|
|
247
237
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
238
|
+
this.initialBufs.length = this.initialBufsLen = 0
|
|
239
|
+
return resStr
|
|
240
|
+
}
|
|
251
241
|
|
|
252
|
-
|
|
253
|
-
}
|
|
242
|
+
return this.decoder.write(buf)
|
|
243
|
+
}
|
|
254
244
|
|
|
255
|
-
Utf32AutoDecoder.prototype.end = function() {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
245
|
+
Utf32AutoDecoder.prototype.end = function () {
|
|
246
|
+
if (!this.decoder) {
|
|
247
|
+
var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding)
|
|
248
|
+
this.decoder = this.iconv.getDecoder(encoding, this.options)
|
|
259
249
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
resStr += this.decoder.write(this.initialBufs[i]);
|
|
250
|
+
var resStr = ""
|
|
251
|
+
for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) }
|
|
263
252
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
resStr += trail;
|
|
253
|
+
var trail = this.decoder.end()
|
|
254
|
+
if (trail) { resStr += trail }
|
|
267
255
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
256
|
+
this.initialBufs.length = this.initialBufsLen = 0
|
|
257
|
+
return resStr
|
|
258
|
+
}
|
|
271
259
|
|
|
272
|
-
|
|
273
|
-
}
|
|
260
|
+
return this.decoder.end()
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function detectEncoding (bufs, defaultEncoding) {
|
|
264
|
+
var b = []
|
|
265
|
+
var charsProcessed = 0
|
|
266
|
+
var invalidLE = 0; var invalidBE = 0 // Number of invalid chars when decoded as LE or BE.
|
|
267
|
+
var bmpCharsLE = 0; var bmpCharsBE = 0 // Number of BMP chars when decoded as LE or BE.
|
|
268
|
+
|
|
269
|
+
outerLoop:
|
|
270
|
+
for (var i = 0; i < bufs.length; i++) {
|
|
271
|
+
var buf = bufs[i]
|
|
272
|
+
for (var j = 0; j < buf.length; j++) {
|
|
273
|
+
b.push(buf[j])
|
|
274
|
+
if (b.length === 4) {
|
|
275
|
+
if (charsProcessed === 0) {
|
|
276
|
+
// Check BOM first.
|
|
277
|
+
if (b[0] === 0xFF && b[1] === 0xFE && b[2] === 0 && b[3] === 0) {
|
|
278
|
+
return "utf-32le"
|
|
279
|
+
}
|
|
280
|
+
if (b[0] === 0 && b[1] === 0 && b[2] === 0xFE && b[3] === 0xFF) {
|
|
281
|
+
return "utf-32be"
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (b[0] !== 0 || b[1] > 0x10) invalidBE++
|
|
286
|
+
if (b[3] !== 0 || b[2] > 0x10) invalidLE++
|
|
287
|
+
|
|
288
|
+
if (b[0] === 0 && b[1] === 0 && (b[2] !== 0 || b[3] !== 0)) bmpCharsBE++
|
|
289
|
+
if ((b[0] !== 0 || b[1] !== 0) && b[2] === 0 && b[3] === 0) bmpCharsLE++
|
|
290
|
+
|
|
291
|
+
b.length = 0
|
|
292
|
+
charsProcessed++
|
|
274
293
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var charsProcessed = 0;
|
|
278
|
-
var invalidLE = 0, invalidBE = 0; // Number of invalid chars when decoded as LE or BE.
|
|
279
|
-
var bmpCharsLE = 0, bmpCharsBE = 0; // Number of BMP chars when decoded as LE or BE.
|
|
280
|
-
|
|
281
|
-
outer_loop:
|
|
282
|
-
for (var i = 0; i < bufs.length; i++) {
|
|
283
|
-
var buf = bufs[i];
|
|
284
|
-
for (var j = 0; j < buf.length; j++) {
|
|
285
|
-
b.push(buf[j]);
|
|
286
|
-
if (b.length === 4) {
|
|
287
|
-
if (charsProcessed === 0) {
|
|
288
|
-
// Check BOM first.
|
|
289
|
-
if (b[0] === 0xFF && b[1] === 0xFE && b[2] === 0 && b[3] === 0) {
|
|
290
|
-
return 'utf-32le';
|
|
291
|
-
}
|
|
292
|
-
if (b[0] === 0 && b[1] === 0 && b[2] === 0xFE && b[3] === 0xFF) {
|
|
293
|
-
return 'utf-32be';
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (b[0] !== 0 || b[1] > 0x10) invalidBE++;
|
|
298
|
-
if (b[3] !== 0 || b[2] > 0x10) invalidLE++;
|
|
299
|
-
|
|
300
|
-
if (b[0] === 0 && b[1] === 0 && (b[2] !== 0 || b[3] !== 0)) bmpCharsBE++;
|
|
301
|
-
if ((b[0] !== 0 || b[1] !== 0) && b[2] === 0 && b[3] === 0) bmpCharsLE++;
|
|
302
|
-
|
|
303
|
-
b.length = 0;
|
|
304
|
-
charsProcessed++;
|
|
305
|
-
|
|
306
|
-
if (charsProcessed >= 100) {
|
|
307
|
-
break outer_loop;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
294
|
+
if (charsProcessed >= 100) {
|
|
295
|
+
break outerLoop
|
|
310
296
|
}
|
|
297
|
+
}
|
|
311
298
|
}
|
|
299
|
+
}
|
|
312
300
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
301
|
+
// Make decisions.
|
|
302
|
+
if (bmpCharsBE - invalidBE > bmpCharsLE - invalidLE) return "utf-32be"
|
|
303
|
+
if (bmpCharsBE - invalidBE < bmpCharsLE - invalidLE) return "utf-32le"
|
|
316
304
|
|
|
317
|
-
|
|
318
|
-
|
|
305
|
+
// Couldn't decide (likely all zeros or not enough data).
|
|
306
|
+
return defaultEncoding || "utf-32le"
|
|
319
307
|
}
|