@pnpm/exe 11.0.0-dev.1005 → 11.0.0-rc.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-gyp-bin/node-gyp +6 -0
- package/dist/node-gyp-bin/node-gyp.cmd +5 -0
- package/dist/node_modules/@gar/promise-retry/LICENSE +20 -0
- package/dist/node_modules/@gar/promise-retry/lib/index.js +62 -0
- package/dist/node_modules/@gar/promise-retry/lib/retry.js +109 -0
- package/dist/node_modules/@gar/promise-retry/package.json +45 -0
- package/dist/node_modules/@isaacs/fs-minipass/LICENSE +15 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +430 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/esm/index.js +420 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/@isaacs/fs-minipass/package.json +72 -0
- package/dist/node_modules/@npmcli/agent/lib/agents.js +206 -0
- package/dist/node_modules/@npmcli/agent/lib/dns.js +53 -0
- package/dist/node_modules/@npmcli/agent/lib/errors.js +61 -0
- package/dist/node_modules/@npmcli/agent/lib/index.js +56 -0
- package/dist/node_modules/@npmcli/agent/lib/options.js +86 -0
- package/dist/node_modules/@npmcli/agent/lib/proxy.js +88 -0
- package/dist/node_modules/@npmcli/agent/package.json +60 -0
- package/dist/node_modules/@npmcli/fs/lib/common/get-options.js +20 -0
- package/dist/node_modules/@npmcli/fs/lib/common/node.js +9 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/LICENSE +15 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/errors.js +129 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/index.js +22 -0
- package/dist/node_modules/@npmcli/fs/lib/cp/polyfill.js +428 -0
- package/dist/node_modules/@npmcli/fs/lib/index.js +13 -0
- package/dist/node_modules/@npmcli/fs/lib/move-file.js +78 -0
- package/dist/node_modules/@npmcli/fs/lib/readdir-scoped.js +20 -0
- package/dist/node_modules/@npmcli/fs/lib/with-temp-dir.js +39 -0
- package/dist/node_modules/@npmcli/fs/package.json +54 -0
- package/dist/node_modules/@npmcli/redact/LICENSE +21 -0
- package/dist/node_modules/@npmcli/redact/lib/deep-map.js +71 -0
- package/dist/node_modules/@npmcli/redact/lib/error.js +28 -0
- package/dist/node_modules/@npmcli/redact/lib/index.js +44 -0
- package/dist/node_modules/@npmcli/redact/lib/matchers.js +88 -0
- package/dist/node_modules/@npmcli/redact/lib/server.js +59 -0
- package/dist/node_modules/@npmcli/redact/lib/utils.js +202 -0
- package/dist/node_modules/@npmcli/redact/package.json +52 -0
- package/dist/node_modules/abbrev/LICENSE +46 -0
- package/dist/node_modules/abbrev/lib/index.js +53 -0
- package/dist/node_modules/abbrev/package.json +41 -0
- package/dist/node_modules/agent-base/LICENSE +22 -0
- package/dist/node_modules/agent-base/dist/helpers.js +66 -0
- package/dist/node_modules/agent-base/dist/index.js +178 -0
- package/dist/node_modules/agent-base/package.json +46 -0
- package/dist/node_modules/balanced-match/dist/commonjs/index.js +59 -0
- package/dist/node_modules/balanced-match/dist/commonjs/package.json +3 -0
- package/dist/node_modules/balanced-match/dist/esm/index.js +54 -0
- package/dist/node_modules/balanced-match/dist/esm/package.json +3 -0
- package/dist/node_modules/balanced-match/package.json +68 -0
- package/dist/node_modules/brace-expansion/LICENSE +23 -0
- package/dist/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
- package/dist/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
- package/dist/node_modules/brace-expansion/dist/esm/index.js +197 -0
- package/dist/node_modules/brace-expansion/dist/esm/package.json +3 -0
- package/dist/node_modules/brace-expansion/package.json +64 -0
- package/dist/node_modules/cacache/lib/content/path.js +29 -0
- package/dist/node_modules/cacache/lib/content/read.js +165 -0
- package/dist/node_modules/cacache/lib/content/rm.js +18 -0
- package/dist/node_modules/cacache/lib/content/write.js +206 -0
- package/dist/node_modules/cacache/lib/entry-index.js +336 -0
- package/dist/node_modules/cacache/lib/get.js +170 -0
- package/dist/node_modules/cacache/lib/index.js +42 -0
- package/dist/node_modules/cacache/lib/memoization.js +72 -0
- package/dist/node_modules/cacache/lib/put.js +80 -0
- package/dist/node_modules/cacache/lib/rm.js +31 -0
- package/dist/node_modules/cacache/lib/util/glob.js +7 -0
- package/dist/node_modules/cacache/lib/util/hash-to-segments.js +7 -0
- package/dist/node_modules/cacache/lib/util/tmp.js +32 -0
- package/dist/node_modules/cacache/lib/verify.js +258 -0
- package/dist/node_modules/cacache/package.json +81 -0
- package/dist/node_modules/chownr/dist/commonjs/index.js +93 -0
- package/dist/node_modules/chownr/dist/commonjs/package.json +3 -0
- package/dist/node_modules/chownr/dist/esm/index.js +85 -0
- package/dist/node_modules/chownr/dist/esm/package.json +3 -0
- package/dist/node_modules/chownr/package.json +69 -0
- package/dist/node_modules/debug/LICENSE +20 -0
- package/dist/node_modules/debug/package.json +64 -0
- package/dist/node_modules/debug/src/browser.js +272 -0
- package/dist/node_modules/debug/src/common.js +292 -0
- package/dist/node_modules/debug/src/index.js +10 -0
- package/dist/node_modules/debug/src/node.js +263 -0
- package/dist/node_modules/env-paths/index.js +74 -0
- package/dist/node_modules/env-paths/license +9 -0
- package/dist/node_modules/env-paths/package.json +45 -0
- package/dist/node_modules/exponential-backoff/LICENSE +202 -0
- package/dist/node_modules/exponential-backoff/dist/backoff.js +124 -0
- package/dist/node_modules/exponential-backoff/dist/delay/always/always.delay.js +25 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.base.js +45 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.factory.js +17 -0
- package/dist/node_modules/exponential-backoff/dist/delay/delay.interface.js +3 -0
- package/dist/node_modules/exponential-backoff/dist/delay/skip-first/skip-first.delay.js +82 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/full/full.jitter.js +8 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/jitter.factory.js +15 -0
- package/dist/node_modules/exponential-backoff/dist/jitter/no/no.jitter.js +7 -0
- package/dist/node_modules/exponential-backoff/dist/options.js +31 -0
- package/dist/node_modules/exponential-backoff/package.json +62 -0
- package/dist/node_modules/fdir/LICENSE +7 -0
- package/dist/node_modules/fdir/dist/index.cjs +588 -0
- package/dist/node_modules/fdir/dist/index.d.cts +155 -0
- package/dist/node_modules/fdir/dist/index.d.mts +155 -0
- package/dist/node_modules/fdir/dist/index.mjs +570 -0
- package/dist/node_modules/fdir/package.json +103 -0
- package/dist/node_modules/fs-minipass/LICENSE +15 -0
- package/dist/node_modules/fs-minipass/lib/index.js +443 -0
- package/dist/node_modules/fs-minipass/package.json +54 -0
- package/dist/node_modules/glob/dist/commonjs/glob.js +248 -0
- package/dist/node_modules/glob/dist/commonjs/has-magic.js +27 -0
- package/dist/node_modules/glob/dist/commonjs/ignore.js +119 -0
- package/dist/node_modules/glob/dist/commonjs/index.js +68 -0
- package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/glob/dist/commonjs/package.json +3 -0
- package/dist/node_modules/glob/dist/commonjs/pattern.js +223 -0
- package/dist/node_modules/glob/dist/commonjs/processor.js +301 -0
- package/dist/node_modules/glob/dist/commonjs/walker.js +387 -0
- package/dist/node_modules/glob/dist/esm/glob.js +244 -0
- package/dist/node_modules/glob/dist/esm/has-magic.js +23 -0
- package/dist/node_modules/glob/dist/esm/ignore.js +115 -0
- package/dist/node_modules/glob/dist/esm/index.js +55 -0
- package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/node_modules/glob/dist/esm/package.json +3 -0
- package/dist/node_modules/glob/dist/esm/pattern.js +219 -0
- package/dist/node_modules/glob/dist/esm/processor.js +294 -0
- package/dist/node_modules/glob/dist/esm/walker.js +381 -0
- package/dist/node_modules/glob/package.json +98 -0
- package/dist/node_modules/graceful-fs/LICENSE +15 -0
- package/dist/node_modules/graceful-fs/clone.js +23 -0
- package/dist/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/dist/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/dist/node_modules/graceful-fs/package.json +53 -0
- package/dist/node_modules/graceful-fs/polyfills.js +355 -0
- package/dist/node_modules/http-cache-semantics/LICENSE +9 -0
- package/dist/node_modules/http-cache-semantics/index.js +928 -0
- package/dist/node_modules/http-cache-semantics/package.json +22 -0
- package/dist/node_modules/http-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/http-proxy-agent/dist/index.js +148 -0
- package/dist/node_modules/http-proxy-agent/package.json +47 -0
- package/dist/node_modules/https-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/https-proxy-agent/dist/index.js +180 -0
- package/dist/node_modules/https-proxy-agent/dist/parse-proxy-response.js +101 -0
- package/dist/node_modules/https-proxy-agent/package.json +50 -0
- package/dist/node_modules/iconv-lite/LICENSE +21 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/dist/node_modules/iconv-lite/encodings/index.js +23 -0
- package/dist/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/dist/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/dist/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/dist/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/dist/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/dist/node_modules/iconv-lite/lib/index.js +182 -0
- package/dist/node_modules/iconv-lite/lib/streams.js +105 -0
- package/dist/node_modules/iconv-lite/package.json +70 -0
- package/dist/node_modules/ip-address/LICENSE +19 -0
- package/dist/node_modules/ip-address/dist/address-error.js +12 -0
- package/dist/node_modules/ip-address/dist/common.js +46 -0
- package/dist/node_modules/ip-address/dist/ip-address.js +35 -0
- package/dist/node_modules/ip-address/dist/ipv4.js +360 -0
- package/dist/node_modules/ip-address/dist/ipv6.js +1003 -0
- package/dist/node_modules/ip-address/dist/v4/constants.js +8 -0
- package/dist/node_modules/ip-address/dist/v6/constants.js +76 -0
- package/dist/node_modules/ip-address/dist/v6/helpers.js +45 -0
- package/dist/node_modules/ip-address/dist/v6/regular-expressions.js +95 -0
- package/dist/node_modules/ip-address/package.json +78 -0
- package/dist/node_modules/isexe/dist/commonjs/index.js +56 -0
- package/dist/node_modules/isexe/dist/commonjs/index.min.js +2 -0
- package/dist/node_modules/isexe/dist/commonjs/options.js +3 -0
- package/dist/node_modules/isexe/dist/commonjs/package.json +3 -0
- package/dist/node_modules/isexe/dist/commonjs/posix.js +67 -0
- package/dist/node_modules/isexe/dist/commonjs/win32.js +63 -0
- package/dist/node_modules/isexe/dist/esm/index.js +16 -0
- package/dist/node_modules/isexe/dist/esm/index.min.js +2 -0
- package/dist/node_modules/isexe/dist/esm/options.js +2 -0
- package/dist/node_modules/isexe/dist/esm/package.json +3 -0
- package/dist/node_modules/isexe/dist/esm/posix.js +62 -0
- package/dist/node_modules/isexe/dist/esm/win32.js +58 -0
- package/dist/node_modules/isexe/package.json +78 -0
- package/dist/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +10 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +1692 -0
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/commonjs/package.json +3 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/index.js +1688 -0
- package/dist/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
- package/dist/node_modules/lru-cache/dist/esm/index.js +1688 -0
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +7 -0
- package/dist/node_modules/lru-cache/dist/esm/node/index.js +1688 -0
- package/dist/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
- package/dist/node_modules/lru-cache/dist/esm/package.json +3 -0
- package/dist/node_modules/lru-cache/package.json +126 -0
- package/dist/node_modules/make-fetch-happen/LICENSE +16 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/entry.js +471 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/errors.js +11 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/index.js +49 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/key.js +17 -0
- package/dist/node_modules/make-fetch-happen/lib/cache/policy.js +161 -0
- package/dist/node_modules/make-fetch-happen/lib/fetch.js +118 -0
- package/dist/node_modules/make-fetch-happen/lib/index.js +41 -0
- package/dist/node_modules/make-fetch-happen/lib/options.js +59 -0
- package/dist/node_modules/make-fetch-happen/lib/pipeline.js +41 -0
- package/dist/node_modules/make-fetch-happen/lib/remote.js +134 -0
- package/dist/node_modules/make-fetch-happen/package.json +75 -0
- package/dist/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/dist/node_modules/minimatch/dist/commonjs/ast.js +845 -0
- package/dist/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
- package/dist/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/dist/node_modules/minimatch/dist/commonjs/index.js +1127 -0
- package/dist/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/dist/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/dist/node_modules/minimatch/dist/esm/ast.js +841 -0
- package/dist/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
- package/dist/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/dist/node_modules/minimatch/dist/esm/index.js +1114 -0
- package/dist/node_modules/minimatch/dist/esm/package.json +3 -0
- package/dist/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/dist/node_modules/minimatch/package.json +73 -0
- package/dist/node_modules/minipass/dist/commonjs/index.js +1038 -0
- package/dist/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minipass/dist/esm/index.js +1020 -0
- package/dist/node_modules/minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/minipass/package.json +77 -0
- package/dist/node_modules/minipass-collect/LICENSE +15 -0
- package/dist/node_modules/minipass-collect/index.js +71 -0
- package/dist/node_modules/minipass-collect/package.json +30 -0
- package/dist/node_modules/minipass-fetch/LICENSE +28 -0
- package/dist/node_modules/minipass-fetch/lib/abort-error.js +17 -0
- package/dist/node_modules/minipass-fetch/lib/blob.js +97 -0
- package/dist/node_modules/minipass-fetch/lib/body.js +360 -0
- package/dist/node_modules/minipass-fetch/lib/fetch-error.js +32 -0
- package/dist/node_modules/minipass-fetch/lib/headers.js +267 -0
- package/dist/node_modules/minipass-fetch/lib/index.js +376 -0
- package/dist/node_modules/minipass-fetch/lib/request.js +282 -0
- package/dist/node_modules/minipass-fetch/lib/response.js +90 -0
- package/dist/node_modules/minipass-fetch/package.json +70 -0
- package/dist/node_modules/minipass-flush/index.js +39 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/LICENSE +15 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/index.js +649 -0
- package/dist/node_modules/minipass-flush/node_modules/minipass/package.json +56 -0
- package/dist/node_modules/minipass-flush/package.json +42 -0
- package/dist/node_modules/minipass-pipeline/LICENSE +15 -0
- package/dist/node_modules/minipass-pipeline/index.js +128 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/LICENSE +15 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/index.js +649 -0
- package/dist/node_modules/minipass-pipeline/node_modules/minipass/package.json +56 -0
- package/dist/node_modules/minipass-pipeline/package.json +29 -0
- package/dist/node_modules/minipass-sized/LICENSE +15 -0
- package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
- package/dist/node_modules/minipass-sized/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
- package/dist/node_modules/minipass-sized/dist/esm/package.json +3 -0
- package/dist/node_modules/minipass-sized/package.json +69 -0
- package/dist/node_modules/minizlib/LICENSE +26 -0
- package/dist/node_modules/minizlib/dist/commonjs/constants.js +123 -0
- package/dist/node_modules/minizlib/dist/commonjs/index.js +416 -0
- package/dist/node_modules/minizlib/dist/commonjs/package.json +3 -0
- package/dist/node_modules/minizlib/dist/esm/constants.js +117 -0
- package/dist/node_modules/minizlib/dist/esm/index.js +363 -0
- package/dist/node_modules/minizlib/dist/esm/package.json +3 -0
- package/dist/node_modules/minizlib/package.json +80 -0
- package/dist/node_modules/ms/index.js +162 -0
- package/dist/node_modules/ms/package.json +38 -0
- package/dist/node_modules/negotiator/LICENSE +24 -0
- package/dist/node_modules/negotiator/index.js +83 -0
- package/dist/node_modules/negotiator/lib/charset.js +169 -0
- package/dist/node_modules/negotiator/lib/encoding.js +205 -0
- package/dist/node_modules/negotiator/lib/language.js +179 -0
- package/dist/node_modules/negotiator/lib/mediaType.js +294 -0
- package/dist/node_modules/negotiator/package.json +43 -0
- package/dist/node_modules/node-gyp/.release-please-manifest.json +3 -0
- package/dist/node_modules/node-gyp/LICENSE +24 -0
- package/dist/node_modules/node-gyp/addon.gypi +204 -0
- package/dist/node_modules/node-gyp/bin/node-gyp.js +145 -0
- package/dist/node_modules/node-gyp/eslint.config.js +3 -0
- package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +3 -0
- package/dist/node_modules/node-gyp/gyp/LICENSE +28 -0
- package/dist/node_modules/node-gyp/gyp/data/ninja/build.ninja +4 -0
- package/dist/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +12 -0
- package/dist/node_modules/node-gyp/gyp/gyp +8 -0
- package/dist/node_modules/node-gyp/gyp/gyp.bat +5 -0
- package/dist/node_modules/node-gyp/gyp/gyp_main.py +45 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +365 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +206 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +1283 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +1545 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +59 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +152 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +270 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +599 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +707 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/common.py +725 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +186 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +170 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +113 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +55 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +805 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +1169 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +1316 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +128 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +104 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +461 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +88 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +55 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +2755 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +3970 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +44 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +2956 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +67 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +1389 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +26 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/input.py +3097 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +99 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +765 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +1255 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +174 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +61 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +371 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +1936 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +54 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +301 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +3180 -0
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +64 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +3 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +177 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +23 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +15 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +107 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +252 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +83 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +359 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +61 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +192 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/markers.py +251 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +824 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +90 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +1030 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/tags.py +553 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/utils.py +172 -0
- package/dist/node_modules/node-gyp/gyp/pylib/packaging/version.py +563 -0
- package/dist/node_modules/node-gyp/gyp/pyproject.toml +114 -0
- package/dist/node_modules/node-gyp/gyp/release-please-config.json +11 -0
- package/dist/node_modules/node-gyp/gyp/test_gyp.py +260 -0
- package/dist/node_modules/node-gyp/lib/Find-VisualStudio.cs +250 -0
- package/dist/node_modules/node-gyp/lib/build.js +230 -0
- package/dist/node_modules/node-gyp/lib/clean.js +15 -0
- package/dist/node_modules/node-gyp/lib/configure.js +328 -0
- package/dist/node_modules/node-gyp/lib/create-config-gypi.js +153 -0
- package/dist/node_modules/node-gyp/lib/download.js +39 -0
- package/dist/node_modules/node-gyp/lib/find-node-directory.js +63 -0
- package/dist/node_modules/node-gyp/lib/find-python.js +304 -0
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +606 -0
- package/dist/node_modules/node-gyp/lib/install.js +411 -0
- package/dist/node_modules/node-gyp/lib/list.js +26 -0
- package/dist/node_modules/node-gyp/lib/log.js +168 -0
- package/dist/node_modules/node-gyp/lib/node-gyp.js +199 -0
- package/dist/node_modules/node-gyp/lib/process-release.js +146 -0
- package/dist/node_modules/node-gyp/lib/rebuild.js +12 -0
- package/dist/node_modules/node-gyp/lib/remove.js +43 -0
- package/dist/node_modules/node-gyp/lib/util.js +81 -0
- package/dist/node_modules/node-gyp/macOS_Catalina_acid_test.sh +21 -0
- package/dist/node_modules/node-gyp/package.json +52 -0
- package/dist/node_modules/node-gyp/release-please-config.json +40 -0
- package/dist/node_modules/node-gyp/src/win_delay_load_hook.cc +41 -0
- package/dist/node_modules/nopt/LICENSE +15 -0
- package/dist/node_modules/nopt/bin/nopt.js +29 -0
- package/dist/node_modules/nopt/lib/debug.js +5 -0
- package/dist/node_modules/nopt/lib/nopt-lib.js +514 -0
- package/dist/node_modules/nopt/lib/nopt.js +34 -0
- package/dist/node_modules/nopt/lib/type-defs.js +91 -0
- package/dist/node_modules/nopt/package.json +52 -0
- package/dist/node_modules/p-map/index.js +283 -0
- package/dist/node_modules/p-map/license +9 -0
- package/dist/node_modules/p-map/package.json +57 -0
- package/dist/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
- package/dist/node_modules/path-scurry/dist/commonjs/package.json +3 -0
- package/dist/node_modules/path-scurry/dist/esm/index.js +1983 -0
- package/dist/node_modules/path-scurry/dist/esm/package.json +3 -0
- package/dist/node_modules/path-scurry/package.json +72 -0
- package/dist/node_modules/picomatch/LICENSE +21 -0
- package/dist/node_modules/picomatch/index.js +17 -0
- package/dist/node_modules/picomatch/lib/constants.js +184 -0
- package/dist/node_modules/picomatch/lib/parse.js +1386 -0
- package/dist/node_modules/picomatch/lib/picomatch.js +349 -0
- package/dist/node_modules/picomatch/lib/scan.js +391 -0
- package/dist/node_modules/picomatch/lib/utils.js +72 -0
- package/dist/node_modules/picomatch/package.json +82 -0
- package/dist/node_modules/picomatch/posix.js +3 -0
- package/dist/node_modules/proc-log/LICENSE +15 -0
- package/dist/node_modules/proc-log/lib/index.js +158 -0
- package/dist/node_modules/proc-log/package.json +46 -0
- package/dist/node_modules/safer-buffer/LICENSE +21 -0
- package/dist/node_modules/safer-buffer/dangerous.js +58 -0
- package/dist/node_modules/safer-buffer/package.json +34 -0
- package/dist/node_modules/safer-buffer/safer.js +77 -0
- package/dist/node_modules/safer-buffer/tests.js +406 -0
- package/dist/node_modules/semver/LICENSE +15 -0
- package/dist/node_modules/semver/bin/semver.js +191 -0
- package/dist/node_modules/semver/classes/comparator.js +143 -0
- package/dist/node_modules/semver/classes/index.js +7 -0
- package/dist/node_modules/semver/classes/range.js +557 -0
- package/dist/node_modules/semver/classes/semver.js +333 -0
- package/dist/node_modules/semver/functions/clean.js +8 -0
- package/dist/node_modules/semver/functions/cmp.js +54 -0
- package/dist/node_modules/semver/functions/coerce.js +62 -0
- package/dist/node_modules/semver/functions/compare-build.js +9 -0
- package/dist/node_modules/semver/functions/compare-loose.js +5 -0
- package/dist/node_modules/semver/functions/compare.js +7 -0
- package/dist/node_modules/semver/functions/diff.js +60 -0
- package/dist/node_modules/semver/functions/eq.js +5 -0
- package/dist/node_modules/semver/functions/gt.js +5 -0
- package/dist/node_modules/semver/functions/gte.js +5 -0
- package/dist/node_modules/semver/functions/inc.js +21 -0
- package/dist/node_modules/semver/functions/lt.js +5 -0
- package/dist/node_modules/semver/functions/lte.js +5 -0
- package/dist/node_modules/semver/functions/major.js +5 -0
- package/dist/node_modules/semver/functions/minor.js +5 -0
- package/dist/node_modules/semver/functions/neq.js +5 -0
- package/dist/node_modules/semver/functions/parse.js +18 -0
- package/dist/node_modules/semver/functions/patch.js +5 -0
- package/dist/node_modules/semver/functions/prerelease.js +8 -0
- package/dist/node_modules/semver/functions/rcompare.js +5 -0
- package/dist/node_modules/semver/functions/rsort.js +5 -0
- package/dist/node_modules/semver/functions/satisfies.js +12 -0
- package/dist/node_modules/semver/functions/sort.js +5 -0
- package/dist/node_modules/semver/functions/valid.js +8 -0
- package/dist/node_modules/semver/index.js +91 -0
- package/dist/node_modules/semver/internal/constants.js +37 -0
- package/dist/node_modules/semver/internal/debug.js +11 -0
- package/dist/node_modules/semver/internal/identifiers.js +29 -0
- package/dist/node_modules/semver/internal/lrucache.js +42 -0
- package/dist/node_modules/semver/internal/parse-options.js +17 -0
- package/dist/node_modules/semver/internal/re.js +223 -0
- package/dist/node_modules/semver/package.json +78 -0
- package/dist/node_modules/semver/preload.js +4 -0
- package/dist/node_modules/semver/range.bnf +16 -0
- package/dist/node_modules/semver/ranges/gtr.js +6 -0
- package/dist/node_modules/semver/ranges/intersects.js +9 -0
- package/dist/node_modules/semver/ranges/ltr.js +6 -0
- package/dist/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/dist/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/dist/node_modules/semver/ranges/min-version.js +63 -0
- package/dist/node_modules/semver/ranges/outside.js +82 -0
- package/dist/node_modules/semver/ranges/simplify.js +49 -0
- package/dist/node_modules/semver/ranges/subset.js +249 -0
- package/dist/node_modules/semver/ranges/to-comparators.js +10 -0
- package/dist/node_modules/semver/ranges/valid.js +13 -0
- package/dist/node_modules/smart-buffer/.prettierrc.yaml +5 -0
- package/dist/node_modules/smart-buffer/LICENSE +20 -0
- package/dist/node_modules/smart-buffer/build/smartbuffer.js +1233 -0
- package/dist/node_modules/smart-buffer/build/utils.js +108 -0
- package/dist/node_modules/smart-buffer/package.json +79 -0
- package/dist/node_modules/socks/.eslintrc.cjs +11 -0
- package/dist/node_modules/socks/.prettierrc.yaml +7 -0
- package/dist/node_modules/socks/LICENSE +20 -0
- package/dist/node_modules/socks/build/client/socksclient.js +793 -0
- package/dist/node_modules/socks/build/common/constants.js +108 -0
- package/dist/node_modules/socks/build/common/helpers.js +167 -0
- package/dist/node_modules/socks/build/common/receivebuffer.js +43 -0
- package/dist/node_modules/socks/build/common/util.js +25 -0
- package/dist/node_modules/socks/build/index.js +18 -0
- package/dist/node_modules/socks/package.json +58 -0
- package/dist/node_modules/socks-proxy-agent/LICENSE +22 -0
- package/dist/node_modules/socks-proxy-agent/dist/index.js +195 -0
- package/dist/node_modules/socks-proxy-agent/package.json +142 -0
- package/dist/node_modules/ssri/lib/index.js +550 -0
- package/dist/node_modules/ssri/package.json +66 -0
- package/dist/node_modules/tar/dist/commonjs/create.js +82 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/extract.js +88 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
- package/dist/node_modules/tar/dist/commonjs/header.js +312 -0
- package/dist/node_modules/tar/dist/commonjs/index.js +64 -0
- package/dist/node_modules/tar/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
- package/dist/node_modules/tar/dist/commonjs/list.js +145 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.js +52 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.js +187 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/node_modules/tar/dist/commonjs/options.js +66 -0
- package/dist/node_modules/tar/dist/commonjs/pack.js +511 -0
- package/dist/node_modules/tar/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/dist/commonjs/parse.js +610 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
- package/dist/node_modules/tar/dist/commonjs/pax.js +158 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.js +7 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.js +136 -0
- package/dist/node_modules/tar/dist/commonjs/replace.js +227 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
- package/dist/node_modules/tar/dist/commonjs/types.js +50 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.js +932 -0
- package/dist/node_modules/tar/dist/commonjs/update.js +33 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.js +31 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.js +14 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.js +698 -0
- package/dist/node_modules/tar/dist/esm/create.js +76 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.js +14 -0
- package/dist/node_modules/tar/dist/esm/extract.js +49 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.js +26 -0
- package/dist/node_modules/tar/dist/esm/header.js +275 -0
- package/dist/node_modules/tar/dist/esm/index.js +20 -0
- package/dist/node_modules/tar/dist/esm/index.min.js +4 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.js +94 -0
- package/dist/node_modules/tar/dist/esm/list.js +105 -0
- package/dist/node_modules/tar/dist/esm/make-command.js +48 -0
- package/dist/node_modules/tar/dist/esm/mkdir.js +179 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.js +25 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
- package/dist/node_modules/tar/dist/esm/options.js +54 -0
- package/dist/node_modules/tar/dist/esm/pack.js +469 -0
- package/dist/node_modules/tar/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/dist/esm/parse.js +606 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.js +166 -0
- package/dist/node_modules/tar/dist/esm/pax.js +154 -0
- package/dist/node_modules/tar/dist/esm/process-umask.js +3 -0
- package/dist/node_modules/tar/dist/esm/read-entry.js +132 -0
- package/dist/node_modules/tar/dist/esm/replace.js +221 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.js +15 -0
- package/dist/node_modules/tar/dist/esm/types.js +45 -0
- package/dist/node_modules/tar/dist/esm/unpack.js +891 -0
- package/dist/node_modules/tar/dist/esm/update.js +30 -0
- package/dist/node_modules/tar/dist/esm/warn-method.js +27 -0
- package/dist/node_modules/tar/dist/esm/winchars.js +9 -0
- package/dist/node_modules/tar/dist/esm/write-entry.js +656 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/package.json +68 -0
- package/dist/node_modules/tar/package.json +297 -0
- package/dist/node_modules/tinyglobby/LICENSE +21 -0
- package/dist/node_modules/tinyglobby/dist/index.cjs +334 -0
- package/dist/node_modules/tinyglobby/dist/index.d.cts +148 -0
- package/dist/node_modules/tinyglobby/dist/index.d.mts +148 -0
- package/dist/node_modules/tinyglobby/dist/index.mjs +306 -0
- package/dist/node_modules/tinyglobby/package.json +73 -0
- package/{LICENSE → dist/node_modules/v8-compile-cache/LICENSE} +1 -2
- package/dist/node_modules/v8-compile-cache/package.json +34 -0
- package/dist/node_modules/v8-compile-cache/v8-compile-cache.js +373 -0
- package/dist/node_modules/which/LICENSE +15 -0
- package/dist/node_modules/which/bin/which.js +52 -0
- package/dist/node_modules/which/lib/index.js +111 -0
- package/dist/node_modules/which/package.json +52 -0
- package/dist/node_modules/yallist/LICENSE +15 -0
- package/dist/node_modules/yallist/iterator.js +8 -0
- package/dist/node_modules/yallist/package.json +29 -0
- package/dist/node_modules/yallist/yallist.js +426 -0
- package/dist/pnpm.mjs +267218 -0
- package/dist/pnpmrc +2 -0
- package/dist/templates/completion.bash +31 -0
- package/dist/templates/completion.fish +22 -0
- package/dist/templates/completion.ps1 +193 -0
- package/dist/templates/completion.zsh +27 -0
- package/dist/vendor/fastlist-0.3.0-x64.exe +0 -0
- package/dist/vendor/fastlist-0.3.0-x86.exe +0 -0
- package/dist/worker.js +10958 -0
- package/package.json +34 -11
- package/pn +2 -0
- package/pn.cmd +2 -0
- package/pn.ps1 +1 -0
- package/pnpx +2 -0
- package/pnpx.cmd +2 -0
- package/pnpx.ps1 +1 -0
- package/pnx +2 -0
- package/pnx.cmd +2 -0
- package/pnx.ps1 +1 -0
- package/prepare.js +26 -3
- package/setup.js +22 -11
- package/CHANGELOG.md +0 -15
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
var Buffer = require("safer-buffer").Buffer
|
|
3
|
+
|
|
4
|
+
// Multibyte codec. In this scheme, a character is represented by 1 or more bytes.
|
|
5
|
+
// Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.
|
|
6
|
+
// To save memory and loading time, we read table files only when requested.
|
|
7
|
+
|
|
8
|
+
exports._dbcs = DBCSCodec
|
|
9
|
+
|
|
10
|
+
var UNASSIGNED = -1
|
|
11
|
+
var GB18030_CODE = -2
|
|
12
|
+
var SEQ_START = -10
|
|
13
|
+
var NODE_START = -1000
|
|
14
|
+
var UNASSIGNED_NODE = new Array(0x100)
|
|
15
|
+
var DEF_CHAR = -1
|
|
16
|
+
|
|
17
|
+
for (var i = 0; i < 0x100; i++) { UNASSIGNED_NODE[i] = UNASSIGNED }
|
|
18
|
+
|
|
19
|
+
// Class DBCSCodec reads and initializes mapping tables.
|
|
20
|
+
function DBCSCodec (codecOptions, iconv) {
|
|
21
|
+
this.encodingName = codecOptions.encodingName
|
|
22
|
+
if (!codecOptions) { throw new Error("DBCS codec is called without the data.") }
|
|
23
|
+
if (!codecOptions.table) { throw new Error("Encoding '" + this.encodingName + "' has no data.") }
|
|
24
|
+
|
|
25
|
+
// Load tables.
|
|
26
|
+
var mappingTable = codecOptions.table()
|
|
27
|
+
|
|
28
|
+
// Decode tables: MBCS -> Unicode.
|
|
29
|
+
|
|
30
|
+
// decodeTables is a trie, encoded as an array of arrays of integers. Internal arrays are trie nodes and all have len = 256.
|
|
31
|
+
// Trie root is decodeTables[0].
|
|
32
|
+
// Values: >= 0 -> unicode character code. can be > 0xFFFF
|
|
33
|
+
// == UNASSIGNED -> unknown/unassigned sequence.
|
|
34
|
+
// == GB18030_CODE -> this is the end of a GB18030 4-byte sequence.
|
|
35
|
+
// <= NODE_START -> index of the next node in our trie to process next byte.
|
|
36
|
+
// <= SEQ_START -> index of the start of a character code sequence, in decodeTableSeq.
|
|
37
|
+
this.decodeTables = []
|
|
38
|
+
this.decodeTables[0] = UNASSIGNED_NODE.slice(0) // Create root node.
|
|
39
|
+
|
|
40
|
+
// Sometimes a MBCS char corresponds to a sequence of unicode chars. We store them as arrays of integers here.
|
|
41
|
+
this.decodeTableSeq = []
|
|
42
|
+
|
|
43
|
+
// Actual mapping tables consist of chunks. Use them to fill up decode tables.
|
|
44
|
+
for (var i = 0; i < mappingTable.length; i++) { this._addDecodeChunk(mappingTable[i]) }
|
|
45
|
+
|
|
46
|
+
// Load & create GB18030 tables when needed.
|
|
47
|
+
if (typeof codecOptions.gb18030 === "function") {
|
|
48
|
+
this.gb18030 = codecOptions.gb18030() // Load GB18030 ranges.
|
|
49
|
+
|
|
50
|
+
// Add GB18030 common decode nodes.
|
|
51
|
+
var commonThirdByteNodeIdx = this.decodeTables.length
|
|
52
|
+
this.decodeTables.push(UNASSIGNED_NODE.slice(0))
|
|
53
|
+
|
|
54
|
+
var commonFourthByteNodeIdx = this.decodeTables.length
|
|
55
|
+
this.decodeTables.push(UNASSIGNED_NODE.slice(0))
|
|
56
|
+
|
|
57
|
+
// Fill out the tree
|
|
58
|
+
var firstByteNode = this.decodeTables[0]
|
|
59
|
+
for (var i = 0x81; i <= 0xFE; i++) {
|
|
60
|
+
var secondByteNode = this.decodeTables[NODE_START - firstByteNode[i]]
|
|
61
|
+
for (var j = 0x30; j <= 0x39; j++) {
|
|
62
|
+
if (secondByteNode[j] === UNASSIGNED) {
|
|
63
|
+
secondByteNode[j] = NODE_START - commonThirdByteNodeIdx
|
|
64
|
+
} else if (secondByteNode[j] > NODE_START) {
|
|
65
|
+
throw new Error("gb18030 decode tables conflict at byte 2")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var thirdByteNode = this.decodeTables[NODE_START - secondByteNode[j]]
|
|
69
|
+
for (var k = 0x81; k <= 0xFE; k++) {
|
|
70
|
+
if (thirdByteNode[k] === UNASSIGNED) {
|
|
71
|
+
thirdByteNode[k] = NODE_START - commonFourthByteNodeIdx
|
|
72
|
+
} else if (thirdByteNode[k] === NODE_START - commonFourthByteNodeIdx) {
|
|
73
|
+
continue
|
|
74
|
+
} else if (thirdByteNode[k] > NODE_START) {
|
|
75
|
+
throw new Error("gb18030 decode tables conflict at byte 3")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var fourthByteNode = this.decodeTables[NODE_START - thirdByteNode[k]]
|
|
79
|
+
for (var l = 0x30; l <= 0x39; l++) {
|
|
80
|
+
if (fourthByteNode[l] === UNASSIGNED) { fourthByteNode[l] = GB18030_CODE }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.defaultCharUnicode = iconv.defaultCharUnicode
|
|
88
|
+
|
|
89
|
+
// Encode tables: Unicode -> DBCS.
|
|
90
|
+
|
|
91
|
+
// `encodeTable` is array mapping from unicode char to encoded char. All its values are integers for performance.
|
|
92
|
+
// Because it can be sparse, it is represented as array of buckets by 256 chars each. Bucket can be null.
|
|
93
|
+
// Values: >= 0 -> it is a normal char. Write the value (if <=256 then 1 byte, if <=65536 then 2 bytes, etc.).
|
|
94
|
+
// == UNASSIGNED -> no conversion found. Output a default char.
|
|
95
|
+
// <= SEQ_START -> it's an index in encodeTableSeq, see below. The character starts a sequence.
|
|
96
|
+
this.encodeTable = []
|
|
97
|
+
|
|
98
|
+
// `encodeTableSeq` is used when a sequence of unicode characters is encoded as a single code. We use a tree of
|
|
99
|
+
// objects where keys correspond to characters in sequence and leafs are the encoded dbcs values. A special DEF_CHAR key
|
|
100
|
+
// means end of sequence (needed when one sequence is a strict subsequence of another).
|
|
101
|
+
// Objects are kept separately from encodeTable to increase performance.
|
|
102
|
+
this.encodeTableSeq = []
|
|
103
|
+
|
|
104
|
+
// Some chars can be decoded, but need not be encoded.
|
|
105
|
+
var skipEncodeChars = {}
|
|
106
|
+
if (codecOptions.encodeSkipVals) {
|
|
107
|
+
for (var i = 0; i < codecOptions.encodeSkipVals.length; i++) {
|
|
108
|
+
var val = codecOptions.encodeSkipVals[i]
|
|
109
|
+
if (typeof val === "number") { skipEncodeChars[val] = true } else {
|
|
110
|
+
for (var j = val.from; j <= val.to; j++) { skipEncodeChars[j] = true }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Use decode trie to recursively fill out encode tables.
|
|
116
|
+
this._fillEncodeTable(0, 0, skipEncodeChars)
|
|
117
|
+
|
|
118
|
+
// Add more encoding pairs when needed.
|
|
119
|
+
if (codecOptions.encodeAdd) {
|
|
120
|
+
for (var uChar in codecOptions.encodeAdd) {
|
|
121
|
+
if (Object.prototype.hasOwnProperty.call(codecOptions.encodeAdd, uChar)) { this._setEncodeChar(uChar.charCodeAt(0), codecOptions.encodeAdd[uChar]) }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.defCharSB = this.encodeTable[0][iconv.defaultCharSingleByte.charCodeAt(0)]
|
|
126
|
+
if (this.defCharSB === UNASSIGNED) this.defCharSB = this.encodeTable[0]["?"]
|
|
127
|
+
if (this.defCharSB === UNASSIGNED) this.defCharSB = "?".charCodeAt(0)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
DBCSCodec.prototype.encoder = DBCSEncoder
|
|
131
|
+
DBCSCodec.prototype.decoder = DBCSDecoder
|
|
132
|
+
|
|
133
|
+
// Decoder helpers
|
|
134
|
+
DBCSCodec.prototype._getDecodeTrieNode = function (addr) {
|
|
135
|
+
var bytes = []
|
|
136
|
+
for (; addr > 0; addr >>>= 8) { bytes.push(addr & 0xFF) }
|
|
137
|
+
if (bytes.length == 0) { bytes.push(0) }
|
|
138
|
+
|
|
139
|
+
var node = this.decodeTables[0]
|
|
140
|
+
for (var i = bytes.length - 1; i > 0; i--) { // Traverse nodes deeper into the trie.
|
|
141
|
+
var val = node[bytes[i]]
|
|
142
|
+
|
|
143
|
+
if (val == UNASSIGNED) { // Create new node.
|
|
144
|
+
node[bytes[i]] = NODE_START - this.decodeTables.length
|
|
145
|
+
this.decodeTables.push(node = UNASSIGNED_NODE.slice(0))
|
|
146
|
+
} else if (val <= NODE_START) { // Existing node.
|
|
147
|
+
node = this.decodeTables[NODE_START - val]
|
|
148
|
+
} else { throw new Error("Overwrite byte in " + this.encodingName + ", addr: " + addr.toString(16)) }
|
|
149
|
+
}
|
|
150
|
+
return node
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
DBCSCodec.prototype._addDecodeChunk = function (chunk) {
|
|
154
|
+
// First element of chunk is the hex mbcs code where we start.
|
|
155
|
+
var curAddr = parseInt(chunk[0], 16)
|
|
156
|
+
|
|
157
|
+
// Choose the decoding node where we'll write our chars.
|
|
158
|
+
var writeTable = this._getDecodeTrieNode(curAddr)
|
|
159
|
+
curAddr = curAddr & 0xFF
|
|
160
|
+
|
|
161
|
+
// Write all other elements of the chunk to the table.
|
|
162
|
+
for (var k = 1; k < chunk.length; k++) {
|
|
163
|
+
var part = chunk[k]
|
|
164
|
+
if (typeof part === "string") { // String, write as-is.
|
|
165
|
+
for (var l = 0; l < part.length;) {
|
|
166
|
+
var code = part.charCodeAt(l++)
|
|
167
|
+
if (code >= 0xD800 && code < 0xDC00) { // Decode surrogate
|
|
168
|
+
var codeTrail = part.charCodeAt(l++)
|
|
169
|
+
if (codeTrail >= 0xDC00 && codeTrail < 0xE000) { writeTable[curAddr++] = 0x10000 + (code - 0xD800) * 0x400 + (codeTrail - 0xDC00) } else { throw new Error("Incorrect surrogate pair in " + this.encodingName + " at chunk " + chunk[0]) }
|
|
170
|
+
} else if (code > 0x0FF0 && code <= 0x0FFF) { // Character sequence (our own encoding used)
|
|
171
|
+
var len = 0xFFF - code + 2
|
|
172
|
+
var seq = []
|
|
173
|
+
for (var m = 0; m < len; m++) { seq.push(part.charCodeAt(l++)) } // Simple variation: don't support surrogates or subsequences in seq.
|
|
174
|
+
|
|
175
|
+
writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length
|
|
176
|
+
this.decodeTableSeq.push(seq)
|
|
177
|
+
} else { writeTable[curAddr++] = code } // Basic char
|
|
178
|
+
}
|
|
179
|
+
} else if (typeof part === "number") { // Integer, meaning increasing sequence starting with prev character.
|
|
180
|
+
var charCode = writeTable[curAddr - 1] + 1
|
|
181
|
+
for (var l = 0; l < part; l++) { writeTable[curAddr++] = charCode++ }
|
|
182
|
+
} else { throw new Error("Incorrect type '" + typeof part + "' given in " + this.encodingName + " at chunk " + chunk[0]) }
|
|
183
|
+
}
|
|
184
|
+
if (curAddr > 0xFF) { throw new Error("Incorrect chunk in " + this.encodingName + " at addr " + chunk[0] + ": too long" + curAddr) }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Encoder helpers
|
|
188
|
+
DBCSCodec.prototype._getEncodeBucket = function (uCode) {
|
|
189
|
+
var high = uCode >> 8 // This could be > 0xFF because of astral characters.
|
|
190
|
+
if (this.encodeTable[high] === undefined) {
|
|
191
|
+
this.encodeTable[high] = UNASSIGNED_NODE.slice(0)
|
|
192
|
+
} // Create bucket on demand.
|
|
193
|
+
return this.encodeTable[high]
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
DBCSCodec.prototype._setEncodeChar = function (uCode, dbcsCode) {
|
|
197
|
+
var bucket = this._getEncodeBucket(uCode)
|
|
198
|
+
var low = uCode & 0xFF
|
|
199
|
+
if (bucket[low] <= SEQ_START) { this.encodeTableSeq[SEQ_START - bucket[low]][DEF_CHAR] = dbcsCode } // There's already a sequence, set a single-char subsequence of it.
|
|
200
|
+
else if (bucket[low] == UNASSIGNED) { bucket[low] = dbcsCode }
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
DBCSCodec.prototype._setEncodeSequence = function (seq, dbcsCode) {
|
|
204
|
+
// Get the root of character tree according to first character of the sequence.
|
|
205
|
+
var uCode = seq[0]
|
|
206
|
+
var bucket = this._getEncodeBucket(uCode)
|
|
207
|
+
var low = uCode & 0xFF
|
|
208
|
+
|
|
209
|
+
var node
|
|
210
|
+
if (bucket[low] <= SEQ_START) {
|
|
211
|
+
// There's already a sequence with - use it.
|
|
212
|
+
node = this.encodeTableSeq[SEQ_START - bucket[low]]
|
|
213
|
+
} else {
|
|
214
|
+
// There was no sequence object - allocate a new one.
|
|
215
|
+
node = {}
|
|
216
|
+
if (bucket[low] !== UNASSIGNED) node[DEF_CHAR] = bucket[low] // If a char was set before - make it a single-char subsequence.
|
|
217
|
+
bucket[low] = SEQ_START - this.encodeTableSeq.length
|
|
218
|
+
this.encodeTableSeq.push(node)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Traverse the character tree, allocating new nodes as needed.
|
|
222
|
+
for (var j = 1; j < seq.length - 1; j++) {
|
|
223
|
+
var oldVal = node[uCode]
|
|
224
|
+
if (typeof oldVal === "object") { node = oldVal } else {
|
|
225
|
+
node = node[uCode] = {}
|
|
226
|
+
if (oldVal !== undefined) { node[DEF_CHAR] = oldVal }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Set the leaf to given dbcsCode.
|
|
231
|
+
uCode = seq[seq.length - 1]
|
|
232
|
+
node[uCode] = dbcsCode
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
DBCSCodec.prototype._fillEncodeTable = function (nodeIdx, prefix, skipEncodeChars) {
|
|
236
|
+
var node = this.decodeTables[nodeIdx]
|
|
237
|
+
var hasValues = false
|
|
238
|
+
var subNodeEmpty = {}
|
|
239
|
+
for (var i = 0; i < 0x100; i++) {
|
|
240
|
+
var uCode = node[i]
|
|
241
|
+
var mbCode = prefix + i
|
|
242
|
+
if (skipEncodeChars[mbCode]) { continue }
|
|
243
|
+
|
|
244
|
+
if (uCode >= 0) {
|
|
245
|
+
this._setEncodeChar(uCode, mbCode)
|
|
246
|
+
hasValues = true
|
|
247
|
+
} else if (uCode <= NODE_START) {
|
|
248
|
+
var subNodeIdx = NODE_START - uCode
|
|
249
|
+
if (!subNodeEmpty[subNodeIdx]) { // Skip empty subtrees (they are too large in gb18030).
|
|
250
|
+
var newPrefix = (mbCode << 8) >>> 0 // NOTE: '>>> 0' keeps 32-bit num positive.
|
|
251
|
+
if (this._fillEncodeTable(subNodeIdx, newPrefix, skipEncodeChars)) { hasValues = true } else { subNodeEmpty[subNodeIdx] = true }
|
|
252
|
+
}
|
|
253
|
+
} else if (uCode <= SEQ_START) {
|
|
254
|
+
this._setEncodeSequence(this.decodeTableSeq[SEQ_START - uCode], mbCode)
|
|
255
|
+
hasValues = true
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return hasValues
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// == Encoder ==================================================================
|
|
262
|
+
|
|
263
|
+
function DBCSEncoder (options, codec) {
|
|
264
|
+
// Encoder state
|
|
265
|
+
this.leadSurrogate = -1
|
|
266
|
+
this.seqObj = undefined
|
|
267
|
+
|
|
268
|
+
// Static data
|
|
269
|
+
this.encodeTable = codec.encodeTable
|
|
270
|
+
this.encodeTableSeq = codec.encodeTableSeq
|
|
271
|
+
this.defaultCharSingleByte = codec.defCharSB
|
|
272
|
+
this.gb18030 = codec.gb18030
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
DBCSEncoder.prototype.write = function (str) {
|
|
276
|
+
var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3))
|
|
277
|
+
var leadSurrogate = this.leadSurrogate
|
|
278
|
+
var seqObj = this.seqObj
|
|
279
|
+
var nextChar = -1
|
|
280
|
+
var i = 0; var j = 0
|
|
281
|
+
|
|
282
|
+
while (true) {
|
|
283
|
+
// 0. Get next character.
|
|
284
|
+
if (nextChar === -1) {
|
|
285
|
+
if (i == str.length) break
|
|
286
|
+
var uCode = str.charCodeAt(i++)
|
|
287
|
+
} else {
|
|
288
|
+
var uCode = nextChar
|
|
289
|
+
nextChar = -1
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// 1. Handle surrogates.
|
|
293
|
+
if (uCode >= 0xD800 && uCode < 0xE000) { // Char is one of surrogates.
|
|
294
|
+
if (uCode < 0xDC00) { // We've got lead surrogate.
|
|
295
|
+
if (leadSurrogate === -1) {
|
|
296
|
+
leadSurrogate = uCode
|
|
297
|
+
continue
|
|
298
|
+
} else {
|
|
299
|
+
leadSurrogate = uCode
|
|
300
|
+
// Double lead surrogate found.
|
|
301
|
+
uCode = UNASSIGNED
|
|
302
|
+
}
|
|
303
|
+
} else { // We've got trail surrogate.
|
|
304
|
+
if (leadSurrogate !== -1) {
|
|
305
|
+
uCode = 0x10000 + (leadSurrogate - 0xD800) * 0x400 + (uCode - 0xDC00)
|
|
306
|
+
leadSurrogate = -1
|
|
307
|
+
} else {
|
|
308
|
+
// Incomplete surrogate pair - only trail surrogate found.
|
|
309
|
+
uCode = UNASSIGNED
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
} else if (leadSurrogate !== -1) {
|
|
313
|
+
// Incomplete surrogate pair - only lead surrogate found.
|
|
314
|
+
nextChar = uCode; uCode = UNASSIGNED // Write an error, then current char.
|
|
315
|
+
leadSurrogate = -1
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 2. Convert uCode character.
|
|
319
|
+
var dbcsCode = UNASSIGNED
|
|
320
|
+
if (seqObj !== undefined && uCode != UNASSIGNED) { // We are in the middle of the sequence
|
|
321
|
+
var resCode = seqObj[uCode]
|
|
322
|
+
if (typeof resCode === "object") { // Sequence continues.
|
|
323
|
+
seqObj = resCode
|
|
324
|
+
continue
|
|
325
|
+
} else if (typeof resCode === "number") { // Sequence finished. Write it.
|
|
326
|
+
dbcsCode = resCode
|
|
327
|
+
} else if (resCode == undefined) { // Current character is not part of the sequence.
|
|
328
|
+
// Try default character for this sequence
|
|
329
|
+
resCode = seqObj[DEF_CHAR]
|
|
330
|
+
if (resCode !== undefined) {
|
|
331
|
+
dbcsCode = resCode // Found. Write it.
|
|
332
|
+
nextChar = uCode // Current character will be written too in the next iteration.
|
|
333
|
+
} else {
|
|
334
|
+
// TODO: What if we have no default? (resCode == undefined)
|
|
335
|
+
// Then, we should write first char of the sequence as-is and try the rest recursively.
|
|
336
|
+
// Didn't do it for now because no encoding has this situation yet.
|
|
337
|
+
// Currently, just skip the sequence and write current char.
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
seqObj = undefined
|
|
341
|
+
} else if (uCode >= 0) { // Regular character
|
|
342
|
+
var subtable = this.encodeTable[uCode >> 8]
|
|
343
|
+
if (subtable !== undefined) { dbcsCode = subtable[uCode & 0xFF] }
|
|
344
|
+
|
|
345
|
+
if (dbcsCode <= SEQ_START) { // Sequence start
|
|
346
|
+
seqObj = this.encodeTableSeq[SEQ_START - dbcsCode]
|
|
347
|
+
continue
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (dbcsCode == UNASSIGNED && this.gb18030) {
|
|
351
|
+
// Use GB18030 algorithm to find character(s) to write.
|
|
352
|
+
var idx = findIdx(this.gb18030.uChars, uCode)
|
|
353
|
+
if (idx != -1) {
|
|
354
|
+
var dbcsCode = this.gb18030.gbChars[idx] + (uCode - this.gb18030.uChars[idx])
|
|
355
|
+
newBuf[j++] = 0x81 + Math.floor(dbcsCode / 12600); dbcsCode = dbcsCode % 12600
|
|
356
|
+
newBuf[j++] = 0x30 + Math.floor(dbcsCode / 1260); dbcsCode = dbcsCode % 1260
|
|
357
|
+
newBuf[j++] = 0x81 + Math.floor(dbcsCode / 10); dbcsCode = dbcsCode % 10
|
|
358
|
+
newBuf[j++] = 0x30 + dbcsCode
|
|
359
|
+
continue
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// 3. Write dbcsCode character.
|
|
365
|
+
if (dbcsCode === UNASSIGNED) { dbcsCode = this.defaultCharSingleByte }
|
|
366
|
+
|
|
367
|
+
if (dbcsCode < 0x100) {
|
|
368
|
+
newBuf[j++] = dbcsCode
|
|
369
|
+
} else if (dbcsCode < 0x10000) {
|
|
370
|
+
newBuf[j++] = dbcsCode >> 8 // high byte
|
|
371
|
+
newBuf[j++] = dbcsCode & 0xFF // low byte
|
|
372
|
+
} else if (dbcsCode < 0x1000000) {
|
|
373
|
+
newBuf[j++] = dbcsCode >> 16
|
|
374
|
+
newBuf[j++] = (dbcsCode >> 8) & 0xFF
|
|
375
|
+
newBuf[j++] = dbcsCode & 0xFF
|
|
376
|
+
} else {
|
|
377
|
+
newBuf[j++] = dbcsCode >>> 24
|
|
378
|
+
newBuf[j++] = (dbcsCode >>> 16) & 0xFF
|
|
379
|
+
newBuf[j++] = (dbcsCode >>> 8) & 0xFF
|
|
380
|
+
newBuf[j++] = dbcsCode & 0xFF
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
this.seqObj = seqObj
|
|
385
|
+
this.leadSurrogate = leadSurrogate
|
|
386
|
+
return newBuf.slice(0, j)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
DBCSEncoder.prototype.end = function () {
|
|
390
|
+
if (this.leadSurrogate === -1 && this.seqObj === undefined) { return } // All clean. Most often case.
|
|
391
|
+
|
|
392
|
+
var newBuf = Buffer.alloc(10); var j = 0
|
|
393
|
+
|
|
394
|
+
if (this.seqObj) { // We're in the sequence.
|
|
395
|
+
var dbcsCode = this.seqObj[DEF_CHAR]
|
|
396
|
+
if (dbcsCode !== undefined) { // Write beginning of the sequence.
|
|
397
|
+
if (dbcsCode < 0x100) {
|
|
398
|
+
newBuf[j++] = dbcsCode
|
|
399
|
+
} else {
|
|
400
|
+
newBuf[j++] = dbcsCode >> 8 // high byte
|
|
401
|
+
newBuf[j++] = dbcsCode & 0xFF // low byte
|
|
402
|
+
}
|
|
403
|
+
} else {
|
|
404
|
+
// See todo above.
|
|
405
|
+
}
|
|
406
|
+
this.seqObj = undefined
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (this.leadSurrogate !== -1) {
|
|
410
|
+
// Incomplete surrogate pair - only lead surrogate found.
|
|
411
|
+
newBuf[j++] = this.defaultCharSingleByte
|
|
412
|
+
this.leadSurrogate = -1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return newBuf.slice(0, j)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Export for testing
|
|
419
|
+
DBCSEncoder.prototype.findIdx = findIdx
|
|
420
|
+
|
|
421
|
+
// == Decoder ==================================================================
|
|
422
|
+
|
|
423
|
+
function DBCSDecoder (options, codec) {
|
|
424
|
+
// Decoder state
|
|
425
|
+
this.nodeIdx = 0
|
|
426
|
+
this.prevBytes = []
|
|
427
|
+
|
|
428
|
+
// Static data
|
|
429
|
+
this.decodeTables = codec.decodeTables
|
|
430
|
+
this.decodeTableSeq = codec.decodeTableSeq
|
|
431
|
+
this.defaultCharUnicode = codec.defaultCharUnicode
|
|
432
|
+
this.gb18030 = codec.gb18030
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
DBCSDecoder.prototype.write = function (buf) {
|
|
436
|
+
var newBuf = Buffer.alloc(buf.length * 2)
|
|
437
|
+
var nodeIdx = this.nodeIdx
|
|
438
|
+
var prevBytes = this.prevBytes; var prevOffset = this.prevBytes.length
|
|
439
|
+
var seqStart = -this.prevBytes.length // idx of the start of current parsed sequence.
|
|
440
|
+
var uCode
|
|
441
|
+
|
|
442
|
+
for (var i = 0, j = 0; i < buf.length; i++) {
|
|
443
|
+
var curByte = (i >= 0) ? buf[i] : prevBytes[i + prevOffset]
|
|
444
|
+
|
|
445
|
+
// Lookup in current trie node.
|
|
446
|
+
var uCode = this.decodeTables[nodeIdx][curByte]
|
|
447
|
+
|
|
448
|
+
if (uCode >= 0) {
|
|
449
|
+
// Normal character, just use it.
|
|
450
|
+
} else if (uCode === UNASSIGNED) { // Unknown char.
|
|
451
|
+
// TODO: Callback with seq.
|
|
452
|
+
uCode = this.defaultCharUnicode.charCodeAt(0)
|
|
453
|
+
i = seqStart // Skip one byte ('i' will be incremented by the for loop) and try to parse again.
|
|
454
|
+
} else if (uCode === GB18030_CODE) {
|
|
455
|
+
if (i >= 3) {
|
|
456
|
+
var ptr = (buf[i - 3] - 0x81) * 12600 + (buf[i - 2] - 0x30) * 1260 + (buf[i - 1] - 0x81) * 10 + (curByte - 0x30)
|
|
457
|
+
} else {
|
|
458
|
+
var ptr = (prevBytes[i - 3 + prevOffset] - 0x81) * 12600 +
|
|
459
|
+
(((i - 2 >= 0) ? buf[i - 2] : prevBytes[i - 2 + prevOffset]) - 0x30) * 1260 +
|
|
460
|
+
(((i - 1 >= 0) ? buf[i - 1] : prevBytes[i - 1 + prevOffset]) - 0x81) * 10 +
|
|
461
|
+
(curByte - 0x30)
|
|
462
|
+
}
|
|
463
|
+
var idx = findIdx(this.gb18030.gbChars, ptr)
|
|
464
|
+
uCode = this.gb18030.uChars[idx] + ptr - this.gb18030.gbChars[idx]
|
|
465
|
+
} else if (uCode <= NODE_START) { // Go to next trie node.
|
|
466
|
+
nodeIdx = NODE_START - uCode
|
|
467
|
+
continue
|
|
468
|
+
} else if (uCode <= SEQ_START) { // Output a sequence of chars.
|
|
469
|
+
var seq = this.decodeTableSeq[SEQ_START - uCode]
|
|
470
|
+
for (var k = 0; k < seq.length - 1; k++) {
|
|
471
|
+
uCode = seq[k]
|
|
472
|
+
newBuf[j++] = uCode & 0xFF
|
|
473
|
+
newBuf[j++] = uCode >> 8
|
|
474
|
+
}
|
|
475
|
+
uCode = seq[seq.length - 1]
|
|
476
|
+
} else { throw new Error("iconv-lite internal error: invalid decoding table value " + uCode + " at " + nodeIdx + "/" + curByte) }
|
|
477
|
+
|
|
478
|
+
// Write the character to buffer, handling higher planes using surrogate pair.
|
|
479
|
+
if (uCode >= 0x10000) {
|
|
480
|
+
uCode -= 0x10000
|
|
481
|
+
var uCodeLead = 0xD800 | (uCode >> 10)
|
|
482
|
+
newBuf[j++] = uCodeLead & 0xFF
|
|
483
|
+
newBuf[j++] = uCodeLead >> 8
|
|
484
|
+
|
|
485
|
+
uCode = 0xDC00 | (uCode & 0x3FF)
|
|
486
|
+
}
|
|
487
|
+
newBuf[j++] = uCode & 0xFF
|
|
488
|
+
newBuf[j++] = uCode >> 8
|
|
489
|
+
|
|
490
|
+
// Reset trie node.
|
|
491
|
+
nodeIdx = 0; seqStart = i + 1
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
this.nodeIdx = nodeIdx
|
|
495
|
+
this.prevBytes = (seqStart >= 0)
|
|
496
|
+
? Array.prototype.slice.call(buf, seqStart)
|
|
497
|
+
: prevBytes.slice(seqStart + prevOffset).concat(Array.prototype.slice.call(buf))
|
|
498
|
+
|
|
499
|
+
return newBuf.slice(0, j).toString("ucs2")
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
DBCSDecoder.prototype.end = function () {
|
|
503
|
+
var ret = ""
|
|
504
|
+
|
|
505
|
+
// Try to parse all remaining chars.
|
|
506
|
+
while (this.prevBytes.length > 0) {
|
|
507
|
+
// Skip 1 character in the buffer.
|
|
508
|
+
ret += this.defaultCharUnicode
|
|
509
|
+
var bytesArr = this.prevBytes.slice(1)
|
|
510
|
+
|
|
511
|
+
// Parse remaining as usual.
|
|
512
|
+
this.prevBytes = []
|
|
513
|
+
this.nodeIdx = 0
|
|
514
|
+
if (bytesArr.length > 0) { ret += this.write(bytesArr) }
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
this.prevBytes = []
|
|
518
|
+
this.nodeIdx = 0
|
|
519
|
+
return ret
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Binary search for GB18030. Returns largest i such that table[i] <= val.
|
|
523
|
+
function findIdx (table, val) {
|
|
524
|
+
if (table[0] > val) { return -1 }
|
|
525
|
+
|
|
526
|
+
var l = 0; var r = table.length
|
|
527
|
+
while (l < r - 1) { // always table[l] <= val < table[r]
|
|
528
|
+
var mid = l + ((r - l + 1) >> 1)
|
|
529
|
+
if (table[mid] <= val) { l = mid } else { r = mid }
|
|
530
|
+
}
|
|
531
|
+
return l
|
|
532
|
+
}
|