ali-skills 0.0.21 → 0.0.22
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/node_modules/@ali/cli-skills/dist/cli.mjs +1214 -287
- package/node_modules/@ali/cli-skills/package.json +5 -2
- package/node_modules/@ali/o2-open-client/.editorconfig +11 -0
- package/node_modules/@ali/o2-open-client/README.md +80 -0
- package/node_modules/@ali/o2-open-client/abc.json +8 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.js +82 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.js +306 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.js +178 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.js +14 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.js +1 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.js +53 -0
- package/node_modules/@ali/o2-open-client/es/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/es/common/format.js +43 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.js +33 -0
- package/node_modules/@ali/o2-open-client/es/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/index.js +8 -0
- package/node_modules/@ali/o2-open-client/es/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/es/node/config.js +188 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.js +131 -0
- package/node_modules/@ali/o2-open-client/es/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/es/node/help.js +96 -0
- package/node_modules/@ali/o2-open-client/es/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/es/node/index.js +247 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.js +21 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.js +86 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.js +310 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.js +185 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.js +18 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.js +56 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.js +48 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.js +36 -0
- package/node_modules/@ali/o2-open-client/lib/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/index.js +20 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.js +192 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.js +137 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.js +100 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.js +250 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.js +25 -0
- package/node_modules/@ali/o2-open-client/package.json +46 -0
- package/node_modules/@ali/o2-open-client/playwright.config.ts +54 -0
- package/node_modules/@ali/o2-open-client/tsconfig.es.json +31 -0
- package/node_modules/@ali/o2-open-client/tsconfig.json +31 -0
- package/node_modules/@ali/o2-open-client/tsx2doc.config.js +5 -0
- package/node_modules/@ali/o2-open-client/typings/index.d.ts +36 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +1062 -0
- package/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/node_modules/@types/node/buffer.d.ts +1936 -0
- package/node_modules/@types/node/child_process.d.ts +1475 -0
- package/node_modules/@types/node/cluster.d.ts +577 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4590 -0
- package/node_modules/@types/node/dgram.d.ts +597 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +479 -0
- package/node_modules/@types/node/dns.d.ts +871 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +977 -0
- package/node_modules/@types/node/fs/promises.d.ts +1270 -0
- package/node_modules/@types/node/fs.d.ts +4375 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2049 -0
- package/node_modules/@types/node/http2.d.ts +2631 -0
- package/node_modules/@types/node/https.d.ts +578 -0
- package/node_modules/@types/node/index.d.ts +93 -0
- package/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/node_modules/@types/node/module.d.ts +539 -0
- package/node_modules/@types/node/net.d.ts +1031 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +140 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/node_modules/@types/node/process.d.ts +1961 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/node_modules/@types/node/readline.d.ts +589 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +533 -0
- package/node_modules/@types/node/stream.d.ts +1698 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1787 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +286 -0
- package/node_modules/@types/node/tls.d.ts +1259 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +93 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +964 -0
- package/node_modules/@types/node/util.d.ts +2331 -0
- package/node_modules/@types/node/v8.d.ts +809 -0
- package/node_modules/@types/node/vm.d.ts +1001 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/node_modules/@types/node/zlib.d.ts +598 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/await-event/LICENSE +22 -0
- package/node_modules/await-event/README.md +48 -0
- package/node_modules/await-event/index.js +13 -0
- package/node_modules/await-event/package.json +33 -0
- package/node_modules/await-first/LICENSE +21 -0
- package/node_modules/await-first/README.md +80 -0
- package/node_modules/await-first/lib/index.js +21 -0
- package/node_modules/await-first/package.json +49 -0
- package/node_modules/byte/LICENSE.txt +21 -0
- package/node_modules/byte/README.md +207 -0
- package/node_modules/byte/lib/byte.js +635 -0
- package/node_modules/byte/lib/number.js +82 -0
- package/node_modules/byte/package.json +61 -0
- package/node_modules/chalk/index.d.ts +415 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +68 -0
- package/node_modules/chalk/readme.md +341 -0
- package/node_modules/chalk/source/index.js +229 -0
- package/node_modules/chalk/source/templates.js +134 -0
- package/node_modules/chalk/source/util.js +39 -0
- package/node_modules/circular-json-for-egg/LICENSE.txt +19 -0
- package/node_modules/circular-json-for-egg/README.md +148 -0
- package/node_modules/circular-json-for-egg/build/circular-json.amd.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.amd.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.node.js +207 -0
- package/node_modules/circular-json-for-egg/package.json +42 -0
- package/node_modules/cluster-client/LICENSE +21 -0
- package/node_modules/cluster-client/README.md +319 -0
- package/node_modules/cluster-client/index.js +66 -0
- package/node_modules/cluster-client/lib/api_client.js +74 -0
- package/node_modules/cluster-client/lib/connection.js +180 -0
- package/node_modules/cluster-client/lib/const.js +5 -0
- package/node_modules/cluster-client/lib/default_logger.js +11 -0
- package/node_modules/cluster-client/lib/default_transcode.js +6 -0
- package/node_modules/cluster-client/lib/follower.js +331 -0
- package/node_modules/cluster-client/lib/index.js +213 -0
- package/node_modules/cluster-client/lib/leader.js +437 -0
- package/node_modules/cluster-client/lib/protocol/byte_buffer.js +8 -0
- package/node_modules/cluster-client/lib/protocol/packet.js +103 -0
- package/node_modules/cluster-client/lib/protocol/request.js +17 -0
- package/node_modules/cluster-client/lib/protocol/response.js +14 -0
- package/node_modules/cluster-client/lib/server.js +256 -0
- package/node_modules/cluster-client/lib/symbol.js +20 -0
- package/node_modules/cluster-client/lib/utils.js +103 -0
- package/node_modules/cluster-client/lib/wrapper/base.js +210 -0
- package/node_modules/cluster-client/lib/wrapper/cluster.js +57 -0
- package/node_modules/cluster-client/lib/wrapper/single.js +192 -0
- package/node_modules/cluster-client/package.json +60 -0
- package/node_modules/co/LICENSE +22 -0
- package/node_modules/co/Readme.md +212 -0
- package/node_modules/co/index.js +237 -0
- package/node_modules/co/package.json +34 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/ee-first/LICENSE +22 -0
- package/node_modules/ee-first/README.md +80 -0
- package/node_modules/ee-first/index.js +95 -0
- package/node_modules/ee-first/package.json +29 -0
- package/node_modules/egg-errors/LICENSE +21 -0
- package/node_modules/egg-errors/README.md +259 -0
- package/node_modules/egg-errors/lib/base.d.ts +10 -0
- package/node_modules/egg-errors/lib/base.js +28 -0
- package/node_modules/egg-errors/lib/base_error.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_error.js +13 -0
- package/node_modules/egg-errors/lib/base_exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_exception.js +13 -0
- package/node_modules/egg-errors/lib/error.d.ts +6 -0
- package/node_modules/egg-errors/lib/error.js +13 -0
- package/node_modules/egg-errors/lib/error_options.d.ts +5 -0
- package/node_modules/egg-errors/lib/error_options.js +6 -0
- package/node_modules/egg-errors/lib/error_type.d.ts +6 -0
- package/node_modules/egg-errors/lib/error_type.js +10 -0
- package/node_modules/egg-errors/lib/exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/exception.js +13 -0
- package/node_modules/egg-errors/lib/framework/formatter.d.ts +6 -0
- package/node_modules/egg-errors/lib/framework/formatter.js +29 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.js +32 -0
- package/node_modules/egg-errors/lib/http/400.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/400.js +13 -0
- package/node_modules/egg-errors/lib/http/401.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/401.js +13 -0
- package/node_modules/egg-errors/lib/http/402.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/402.js +13 -0
- package/node_modules/egg-errors/lib/http/403.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/403.js +13 -0
- package/node_modules/egg-errors/lib/http/404.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/404.js +13 -0
- package/node_modules/egg-errors/lib/http/405.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/405.js +13 -0
- package/node_modules/egg-errors/lib/http/406.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/406.js +13 -0
- package/node_modules/egg-errors/lib/http/407.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/407.js +13 -0
- package/node_modules/egg-errors/lib/http/408.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/408.js +13 -0
- package/node_modules/egg-errors/lib/http/409.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/409.js +13 -0
- package/node_modules/egg-errors/lib/http/410.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/410.js +13 -0
- package/node_modules/egg-errors/lib/http/411.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/411.js +13 -0
- package/node_modules/egg-errors/lib/http/412.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/412.js +13 -0
- package/node_modules/egg-errors/lib/http/413.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/413.js +13 -0
- package/node_modules/egg-errors/lib/http/414.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/414.js +13 -0
- package/node_modules/egg-errors/lib/http/415.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/415.js +13 -0
- package/node_modules/egg-errors/lib/http/416.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/416.js +13 -0
- package/node_modules/egg-errors/lib/http/417.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/417.js +13 -0
- package/node_modules/egg-errors/lib/http/418.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/418.js +13 -0
- package/node_modules/egg-errors/lib/http/421.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/421.js +13 -0
- package/node_modules/egg-errors/lib/http/422.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/422.js +13 -0
- package/node_modules/egg-errors/lib/http/423.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/423.js +13 -0
- package/node_modules/egg-errors/lib/http/424.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/424.js +13 -0
- package/node_modules/egg-errors/lib/http/425.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/425.js +13 -0
- package/node_modules/egg-errors/lib/http/426.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/426.js +13 -0
- package/node_modules/egg-errors/lib/http/428.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/428.js +13 -0
- package/node_modules/egg-errors/lib/http/429.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/429.js +13 -0
- package/node_modules/egg-errors/lib/http/431.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/431.js +13 -0
- package/node_modules/egg-errors/lib/http/451.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/451.js +13 -0
- package/node_modules/egg-errors/lib/http/500.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/500.js +13 -0
- package/node_modules/egg-errors/lib/http/501.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/501.js +13 -0
- package/node_modules/egg-errors/lib/http/502.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/502.js +13 -0
- package/node_modules/egg-errors/lib/http/503.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/503.js +13 -0
- package/node_modules/egg-errors/lib/http/504.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/504.js +13 -0
- package/node_modules/egg-errors/lib/http/505.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/505.js +13 -0
- package/node_modules/egg-errors/lib/http/506.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/506.js +13 -0
- package/node_modules/egg-errors/lib/http/507.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/507.js +13 -0
- package/node_modules/egg-errors/lib/http/508.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/508.js +13 -0
- package/node_modules/egg-errors/lib/http/509.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/509.js +13 -0
- package/node_modules/egg-errors/lib/http/510.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/510.js +13 -0
- package/node_modules/egg-errors/lib/http/511.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/511.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/http/http_error.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error_options.d.ts +6 -0
- package/node_modules/egg-errors/lib/http/http_error_options.js +7 -0
- package/node_modules/egg-errors/lib/http/http_header.d.ts +3 -0
- package/node_modules/egg-errors/lib/http/http_header.js +3 -0
- package/node_modules/egg-errors/lib/index.d.ts +50 -0
- package/node_modules/egg-errors/lib/index.js +149 -0
- package/node_modules/egg-errors/package.json +49 -0
- package/node_modules/egg-logger/LICENSE +21 -0
- package/node_modules/egg-logger/README.md +128 -0
- package/node_modules/egg-logger/README.zh-CN.md +125 -0
- package/node_modules/egg-logger/index.d.ts +233 -0
- package/node_modules/egg-logger/index.js +18 -0
- package/node_modules/egg-logger/lib/egg/console_logger.js +36 -0
- package/node_modules/egg-logger/lib/egg/context_logger.js +43 -0
- package/node_modules/egg-logger/lib/egg/custom_logger.js +10 -0
- package/node_modules/egg-logger/lib/egg/error_logger.js +31 -0
- package/node_modules/egg-logger/lib/egg/logger.js +128 -0
- package/node_modules/egg-logger/lib/egg/loggers.js +163 -0
- package/node_modules/egg-logger/lib/level.js +34 -0
- package/node_modules/egg-logger/lib/logger.js +170 -0
- package/node_modules/egg-logger/lib/transports/console.js +52 -0
- package/node_modules/egg-logger/lib/transports/file.js +134 -0
- package/node_modules/egg-logger/lib/transports/file_buffer.js +113 -0
- package/node_modules/egg-logger/lib/transports/transport.js +129 -0
- package/node_modules/egg-logger/lib/utils.js +296 -0
- package/node_modules/egg-logger/package.json +54 -0
- package/node_modules/escape-html/LICENSE +24 -0
- package/node_modules/escape-html/Readme.md +43 -0
- package/node_modules/escape-html/index.js +78 -0
- package/node_modules/escape-html/package.json +24 -0
- package/node_modules/extend-shallow/LICENSE +21 -0
- package/node_modules/extend-shallow/README.md +61 -0
- package/node_modules/extend-shallow/index.js +33 -0
- package/node_modules/extend-shallow/package.json +56 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/heartbeats/.eslintrc +151 -0
- package/node_modules/heartbeats/.npmignore +28 -0
- package/node_modules/heartbeats/.travis.yml +10 -0
- package/node_modules/heartbeats/LICENSE +21 -0
- package/node_modules/heartbeats/README.md +323 -0
- package/node_modules/heartbeats/lib/beatevent.js +35 -0
- package/node_modules/heartbeats/lib/heart.js +178 -0
- package/node_modules/heartbeats/lib/pulse.js +39 -0
- package/node_modules/heartbeats/main.js +34 -0
- package/node_modules/heartbeats/package.json +39 -0
- package/node_modules/heartbeats/test/benchmark.js +138 -0
- package/node_modules/heartbeats/test/spawn.js +16 -0
- package/node_modules/heartbeats/test/test.js +158 -0
- package/node_modules/httpx/README.md +96 -0
- package/node_modules/httpx/lib/index.d.ts +31 -0
- package/node_modules/httpx/lib/index.js +396 -0
- package/node_modules/httpx/package.json +36 -0
- package/node_modules/iconv-lite/.github/dependabot.yml +11 -0
- package/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
- package/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
- package/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/node_modules/iconv-lite/.idea/modules.xml +8 -0
- package/node_modules/iconv-lite/.idea/vcs.xml +6 -0
- package/node_modules/iconv-lite/Changelog.md +212 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +130 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +198 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +197 -0
- package/node_modules/iconv-lite/encodings/utf32.js +319 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/index.d.ts +41 -0
- package/node_modules/iconv-lite/lib/index.js +180 -0
- package/node_modules/iconv-lite/lib/streams.js +109 -0
- package/node_modules/iconv-lite/package.json +44 -0
- package/node_modules/ip/README.md +90 -0
- package/node_modules/ip/lib/ip.js +496 -0
- package/node_modules/ip/package.json +25 -0
- package/node_modules/is-class-hotfix/.editorconfig +23 -0
- package/node_modules/is-class-hotfix/.gitattributes +2 -0
- package/node_modules/is-class-hotfix/CHANGELOG.md +7 -0
- package/node_modules/is-class-hotfix/LICENSE.md +21 -0
- package/node_modules/is-class-hotfix/README.md +35 -0
- package/node_modules/is-class-hotfix/bower.json +24 -0
- package/node_modules/is-class-hotfix/is-class.js +28 -0
- package/node_modules/is-class-hotfix/package.json +31 -0
- package/node_modules/is-class-hotfix/test/babel-class.js +27 -0
- package/node_modules/is-class-hotfix/test/is-class.js +31 -0
- package/node_modules/is-extendable/LICENSE +21 -0
- package/node_modules/is-extendable/README.md +72 -0
- package/node_modules/is-extendable/index.js +13 -0
- package/node_modules/is-extendable/package.json +51 -0
- package/node_modules/is-type-of/LICENSE +21 -0
- package/node_modules/is-type-of/README.md +105 -0
- package/node_modules/is-type-of/index.d.ts +65 -0
- package/node_modules/is-type-of/index.js +125 -0
- package/node_modules/is-type-of/package.json +45 -0
- package/node_modules/isstream/.jshintrc +59 -0
- package/node_modules/isstream/.npmignore +1 -0
- package/node_modules/isstream/.travis.yml +12 -0
- package/node_modules/isstream/LICENSE.md +11 -0
- package/node_modules/isstream/README.md +66 -0
- package/node_modules/isstream/isstream.js +27 -0
- package/node_modules/isstream/package.json +33 -0
- package/node_modules/isstream/test.js +168 -0
- package/node_modules/json-stringify-safe/.npmignore +1 -0
- package/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
- package/node_modules/json-stringify-safe/LICENSE +15 -0
- package/node_modules/json-stringify-safe/Makefile +35 -0
- package/node_modules/json-stringify-safe/README.md +52 -0
- package/node_modules/json-stringify-safe/package.json +31 -0
- package/node_modules/json-stringify-safe/stringify.js +27 -0
- package/node_modules/json-stringify-safe/test/mocha.opts +2 -0
- package/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
- package/node_modules/kitx/LICENSE +21 -0
- package/node_modules/kitx/README.md +35 -0
- package/node_modules/kitx/lib/index.d.ts +45 -0
- package/node_modules/kitx/lib/index.js +289 -0
- package/node_modules/kitx/package.json +41 -0
- package/node_modules/long/LICENSE +202 -0
- package/node_modules/long/README.md +246 -0
- package/node_modules/long/dist/long.js +2 -0
- package/node_modules/long/dist/long.js.map +1 -0
- package/node_modules/long/index.js +1 -0
- package/node_modules/long/package.json +34 -0
- package/node_modules/long/src/long.js +1323 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/p-timeout/index.d.ts +113 -0
- package/node_modules/p-timeout/index.js +71 -0
- package/node_modules/p-timeout/license +9 -0
- package/node_modules/p-timeout/package.json +44 -0
- package/node_modules/p-timeout/readme.md +117 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/sdk-base/LICENSE +21 -0
- package/node_modules/sdk-base/README.md +165 -0
- package/node_modules/sdk-base/index.d.ts +29 -0
- package/node_modules/sdk-base/index.js +251 -0
- package/node_modules/sdk-base/package.json +54 -0
- package/node_modules/serialize-json/LICENSE +21 -0
- package/node_modules/serialize-json/README.md +74 -0
- package/node_modules/serialize-json/lib/decoder.js +190 -0
- package/node_modules/serialize-json/lib/encoder.js +200 -0
- package/node_modules/serialize-json/lib/index.js +15 -0
- package/node_modules/serialize-json/package.json +53 -0
- package/node_modules/supports-color/browser.js +5 -0
- package/node_modules/supports-color/index.js +135 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +53 -0
- package/node_modules/supports-color/readme.md +76 -0
- package/node_modules/tcp-base/LICENSE +21 -0
- package/node_modules/tcp-base/README.md +134 -0
- package/node_modules/tcp-base/lib/base.js +456 -0
- package/node_modules/tcp-base/package.json +44 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/node_modules/unescape/LICENSE +21 -0
- package/node_modules/unescape/README.md +134 -0
- package/node_modules/unescape/index.js +103 -0
- package/node_modules/unescape/package.json +67 -0
- package/node_modules/utility/LICENSE.txt +21 -0
- package/node_modules/utility/README.md +370 -0
- package/node_modules/utility/dist/commonjs/array.d.ts +11 -0
- package/node_modules/utility/dist/commonjs/array.js +46 -0
- package/node_modules/utility/dist/commonjs/crypto.d.ts +86 -0
- package/node_modules/utility/dist/commonjs/crypto.js +159 -0
- package/node_modules/utility/dist/commonjs/date.d.ts +63 -0
- package/node_modules/utility/dist/commonjs/date.js +219 -0
- package/node_modules/utility/dist/commonjs/fs.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/fs.js +20 -0
- package/node_modules/utility/dist/commonjs/function.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/function.js +35 -0
- package/node_modules/utility/dist/commonjs/index.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/index.js +29 -0
- package/node_modules/utility/dist/commonjs/json.d.ts +14 -0
- package/node_modules/utility/dist/commonjs/json.js +41 -0
- package/node_modules/utility/dist/commonjs/number.d.ts +24 -0
- package/node_modules/utility/dist/commonjs/number.js +66 -0
- package/node_modules/utility/dist/commonjs/object.d.ts +20 -0
- package/node_modules/utility/dist/commonjs/object.js +73 -0
- package/node_modules/utility/dist/commonjs/optimize.d.ts +21 -0
- package/node_modules/utility/dist/commonjs/optimize.js +60 -0
- package/node_modules/utility/dist/commonjs/package.json +3 -0
- package/node_modules/utility/dist/commonjs/string.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/string.js +126 -0
- package/node_modules/utility/dist/commonjs/timeout.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/timeout.js +34 -0
- package/node_modules/utility/dist/commonjs/web.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/web.js +61 -0
- package/node_modules/utility/dist/esm/array.d.ts +11 -0
- package/node_modules/utility/dist/esm/array.js +42 -0
- package/node_modules/utility/dist/esm/crypto.d.ts +86 -0
- package/node_modules/utility/dist/esm/crypto.js +146 -0
- package/node_modules/utility/dist/esm/date.d.ts +63 -0
- package/node_modules/utility/dist/esm/date.js +204 -0
- package/node_modules/utility/dist/esm/fs.d.ts +6 -0
- package/node_modules/utility/dist/esm/fs.js +17 -0
- package/node_modules/utility/dist/esm/function.d.ts +12 -0
- package/node_modules/utility/dist/esm/function.js +28 -0
- package/node_modules/utility/dist/esm/index.d.ts +12 -0
- package/node_modules/utility/dist/esm/index.js +13 -0
- package/node_modules/utility/dist/esm/json.d.ts +14 -0
- package/node_modules/utility/dist/esm/json.js +34 -0
- package/node_modules/utility/dist/esm/number.d.ts +24 -0
- package/node_modules/utility/dist/esm/number.js +60 -0
- package/node_modules/utility/dist/esm/object.d.ts +20 -0
- package/node_modules/utility/dist/esm/object.js +67 -0
- package/node_modules/utility/dist/esm/optimize.d.ts +21 -0
- package/node_modules/utility/dist/esm/optimize.js +54 -0
- package/node_modules/utility/dist/esm/package.json +3 -0
- package/node_modules/utility/dist/esm/string.d.ts +29 -0
- package/node_modules/utility/dist/esm/string.js +118 -0
- package/node_modules/utility/dist/esm/timeout.d.ts +6 -0
- package/node_modules/utility/dist/esm/timeout.js +28 -0
- package/node_modules/utility/dist/esm/web.d.ts +29 -0
- package/node_modules/utility/dist/esm/web.js +52 -0
- package/node_modules/utility/dist/package.json +4 -0
- package/node_modules/utility/package.json +85 -0
- package/node_modules/utility/src/array.ts +44 -0
- package/node_modules/utility/src/crypto.ts +160 -0
- package/node_modules/utility/src/date.ts +232 -0
- package/node_modules/utility/src/fs.ts +17 -0
- package/node_modules/utility/src/function.ts +30 -0
- package/node_modules/utility/src/index.ts +12 -0
- package/node_modules/utility/src/json.ts +48 -0
- package/node_modules/utility/src/number.ts +63 -0
- package/node_modules/utility/src/object.ts +72 -0
- package/node_modules/utility/src/optimize.ts +62 -0
- package/node_modules/utility/src/string.ts +132 -0
- package/node_modules/utility/src/timeout.ts +37 -0
- package/node_modules/utility/src/web.ts +53 -0
- package/node_modules/ylru/LICENSE +25 -0
- package/node_modules/ylru/README.md +120 -0
- package/node_modules/ylru/dist/commonjs/index.d.ts +21 -0
- package/node_modules/ylru/dist/commonjs/index.js +112 -0
- package/node_modules/ylru/dist/commonjs/package.json +3 -0
- package/node_modules/ylru/dist/esm/index.d.ts +21 -0
- package/node_modules/ylru/dist/esm/index.js +108 -0
- package/node_modules/ylru/dist/esm/package.json +3 -0
- package/node_modules/ylru/package.json +71 -0
- package/node_modules/ylru/src/index.ts +124 -0
- package/package.json +2 -2
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/abort-controller.mjs +0 -424
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/archiver.mjs +0 -19586
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var Buffer = require("safer-buffer").Buffer;
|
|
3
|
+
|
|
4
|
+
// UTF-7 codec, according to https://tools.ietf.org/html/rfc2152
|
|
5
|
+
// See also below a UTF-7-IMAP codec, according to http://tools.ietf.org/html/rfc3501#section-5.1.3
|
|
6
|
+
|
|
7
|
+
exports.utf7 = Utf7Codec;
|
|
8
|
+
exports.unicode11utf7 = 'utf7'; // Alias UNICODE-1-1-UTF-7
|
|
9
|
+
function Utf7Codec(codecOptions, iconv) {
|
|
10
|
+
this.iconv = iconv;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Utf7Codec.prototype.encoder = Utf7Encoder;
|
|
14
|
+
Utf7Codec.prototype.decoder = Utf7Decoder;
|
|
15
|
+
Utf7Codec.prototype.bomAware = true;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// -- Encoding
|
|
19
|
+
|
|
20
|
+
var nonDirectChars = /[^A-Za-z0-9'\(\),-\.\/:\? \n\r\t]+/g;
|
|
21
|
+
|
|
22
|
+
function Utf7Encoder(options, codec) {
|
|
23
|
+
this.iconv = codec.iconv;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Utf7Encoder.prototype.write = function(str) {
|
|
27
|
+
// Naive implementation.
|
|
28
|
+
// Non-direct chars are encoded as "+<base64>-"; single "+" char is encoded as "+-".
|
|
29
|
+
return Buffer.from(str.replace(nonDirectChars, function(chunk) {
|
|
30
|
+
return "+" + (chunk === '+' ? '' :
|
|
31
|
+
this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, ''))
|
|
32
|
+
+ "-";
|
|
33
|
+
}.bind(this)));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Utf7Encoder.prototype.end = function() {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// -- Decoding
|
|
41
|
+
|
|
42
|
+
function Utf7Decoder(options, codec) {
|
|
43
|
+
this.iconv = codec.iconv;
|
|
44
|
+
this.inBase64 = false;
|
|
45
|
+
this.base64Accum = '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var base64Regex = /[A-Za-z0-9\/+]/;
|
|
49
|
+
var base64Chars = [];
|
|
50
|
+
for (var i = 0; i < 256; i++)
|
|
51
|
+
base64Chars[i] = base64Regex.test(String.fromCharCode(i));
|
|
52
|
+
|
|
53
|
+
var plusChar = '+'.charCodeAt(0),
|
|
54
|
+
minusChar = '-'.charCodeAt(0),
|
|
55
|
+
andChar = '&'.charCodeAt(0);
|
|
56
|
+
|
|
57
|
+
Utf7Decoder.prototype.write = function(buf) {
|
|
58
|
+
var res = "", lastI = 0,
|
|
59
|
+
inBase64 = this.inBase64,
|
|
60
|
+
base64Accum = this.base64Accum;
|
|
61
|
+
|
|
62
|
+
// The decoder is more involved as we must handle chunks in stream.
|
|
63
|
+
|
|
64
|
+
for (var i = 0; i < buf.length; i++) {
|
|
65
|
+
if (!inBase64) { // We're in direct mode.
|
|
66
|
+
// Write direct chars until '+'
|
|
67
|
+
if (buf[i] == plusChar) {
|
|
68
|
+
res += this.iconv.decode(buf.slice(lastI, i), "ascii"); // Write direct chars.
|
|
69
|
+
lastI = i+1;
|
|
70
|
+
inBase64 = true;
|
|
71
|
+
}
|
|
72
|
+
} else { // We decode base64.
|
|
73
|
+
if (!base64Chars[buf[i]]) { // Base64 ended.
|
|
74
|
+
if (i == lastI && buf[i] == minusChar) {// "+-" -> "+"
|
|
75
|
+
res += "+";
|
|
76
|
+
} else {
|
|
77
|
+
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i), "ascii");
|
|
78
|
+
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (buf[i] != minusChar) // Minus is absorbed after base64.
|
|
82
|
+
i--;
|
|
83
|
+
|
|
84
|
+
lastI = i+1;
|
|
85
|
+
inBase64 = false;
|
|
86
|
+
base64Accum = '';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!inBase64) {
|
|
92
|
+
res += this.iconv.decode(buf.slice(lastI), "ascii"); // Write direct chars.
|
|
93
|
+
} else {
|
|
94
|
+
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI), "ascii");
|
|
95
|
+
|
|
96
|
+
var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.
|
|
97
|
+
base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.
|
|
98
|
+
b64str = b64str.slice(0, canBeDecoded);
|
|
99
|
+
|
|
100
|
+
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.inBase64 = inBase64;
|
|
104
|
+
this.base64Accum = base64Accum;
|
|
105
|
+
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Utf7Decoder.prototype.end = function() {
|
|
110
|
+
var res = "";
|
|
111
|
+
if (this.inBase64 && this.base64Accum.length > 0)
|
|
112
|
+
res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");
|
|
113
|
+
|
|
114
|
+
this.inBase64 = false;
|
|
115
|
+
this.base64Accum = '';
|
|
116
|
+
return res;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
// UTF-7-IMAP codec.
|
|
121
|
+
// RFC3501 Sec. 5.1.3 Modified UTF-7 (http://tools.ietf.org/html/rfc3501#section-5.1.3)
|
|
122
|
+
// Differences:
|
|
123
|
+
// * Base64 part is started by "&" instead of "+"
|
|
124
|
+
// * Direct characters are 0x20-0x7E, except "&" (0x26)
|
|
125
|
+
// * In Base64, "," is used instead of "/"
|
|
126
|
+
// * Base64 must not be used to represent direct characters.
|
|
127
|
+
// * No implicit shift back from Base64 (should always end with '-')
|
|
128
|
+
// * String must end in non-shifted position.
|
|
129
|
+
// * "-&" while in base64 is not allowed.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
exports.utf7imap = Utf7IMAPCodec;
|
|
133
|
+
function Utf7IMAPCodec(codecOptions, iconv) {
|
|
134
|
+
this.iconv = iconv;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
Utf7IMAPCodec.prototype.encoder = Utf7IMAPEncoder;
|
|
138
|
+
Utf7IMAPCodec.prototype.decoder = Utf7IMAPDecoder;
|
|
139
|
+
Utf7IMAPCodec.prototype.bomAware = true;
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
// -- Encoding
|
|
143
|
+
|
|
144
|
+
function Utf7IMAPEncoder(options, codec) {
|
|
145
|
+
this.iconv = codec.iconv;
|
|
146
|
+
this.inBase64 = false;
|
|
147
|
+
this.base64Accum = Buffer.alloc(6);
|
|
148
|
+
this.base64AccumIdx = 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
Utf7IMAPEncoder.prototype.write = function(str) {
|
|
152
|
+
var inBase64 = this.inBase64,
|
|
153
|
+
base64Accum = this.base64Accum,
|
|
154
|
+
base64AccumIdx = this.base64AccumIdx,
|
|
155
|
+
buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0;
|
|
156
|
+
|
|
157
|
+
for (var i = 0; i < str.length; i++) {
|
|
158
|
+
var uChar = str.charCodeAt(i);
|
|
159
|
+
if (0x20 <= uChar && uChar <= 0x7E) { // Direct character or '&'.
|
|
160
|
+
if (inBase64) {
|
|
161
|
+
if (base64AccumIdx > 0) {
|
|
162
|
+
bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString('base64').replace(/\//g, ',').replace(/=+$/, ''), bufIdx);
|
|
163
|
+
base64AccumIdx = 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.
|
|
167
|
+
inBase64 = false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!inBase64) {
|
|
171
|
+
buf[bufIdx++] = uChar; // Write direct character
|
|
172
|
+
|
|
173
|
+
if (uChar === andChar) // Ampersand -> '&-'
|
|
174
|
+
buf[bufIdx++] = minusChar;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
} else { // Non-direct character
|
|
178
|
+
if (!inBase64) {
|
|
179
|
+
buf[bufIdx++] = andChar; // Write '&', then go to base64 mode.
|
|
180
|
+
inBase64 = true;
|
|
181
|
+
}
|
|
182
|
+
if (inBase64) {
|
|
183
|
+
base64Accum[base64AccumIdx++] = uChar >> 8;
|
|
184
|
+
base64Accum[base64AccumIdx++] = uChar & 0xFF;
|
|
185
|
+
|
|
186
|
+
if (base64AccumIdx == base64Accum.length) {
|
|
187
|
+
bufIdx += buf.write(base64Accum.toString('base64').replace(/\//g, ','), bufIdx);
|
|
188
|
+
base64AccumIdx = 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this.inBase64 = inBase64;
|
|
195
|
+
this.base64AccumIdx = base64AccumIdx;
|
|
196
|
+
|
|
197
|
+
return buf.slice(0, bufIdx);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Utf7IMAPEncoder.prototype.end = function() {
|
|
201
|
+
var buf = Buffer.alloc(10), bufIdx = 0;
|
|
202
|
+
if (this.inBase64) {
|
|
203
|
+
if (this.base64AccumIdx > 0) {
|
|
204
|
+
bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString('base64').replace(/\//g, ',').replace(/=+$/, ''), bufIdx);
|
|
205
|
+
this.base64AccumIdx = 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
buf[bufIdx++] = minusChar; // Write '-', then go to direct mode.
|
|
209
|
+
this.inBase64 = false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return buf.slice(0, bufIdx);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
// -- Decoding
|
|
217
|
+
|
|
218
|
+
function Utf7IMAPDecoder(options, codec) {
|
|
219
|
+
this.iconv = codec.iconv;
|
|
220
|
+
this.inBase64 = false;
|
|
221
|
+
this.base64Accum = '';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var base64IMAPChars = base64Chars.slice();
|
|
225
|
+
base64IMAPChars[','.charCodeAt(0)] = true;
|
|
226
|
+
|
|
227
|
+
Utf7IMAPDecoder.prototype.write = function(buf) {
|
|
228
|
+
var res = "", lastI = 0,
|
|
229
|
+
inBase64 = this.inBase64,
|
|
230
|
+
base64Accum = this.base64Accum;
|
|
231
|
+
|
|
232
|
+
// The decoder is more involved as we must handle chunks in stream.
|
|
233
|
+
// It is forgiving, closer to standard UTF-7 (for example, '-' is optional at the end).
|
|
234
|
+
|
|
235
|
+
for (var i = 0; i < buf.length; i++) {
|
|
236
|
+
if (!inBase64) { // We're in direct mode.
|
|
237
|
+
// Write direct chars until '&'
|
|
238
|
+
if (buf[i] == andChar) {
|
|
239
|
+
res += this.iconv.decode(buf.slice(lastI, i), "ascii"); // Write direct chars.
|
|
240
|
+
lastI = i+1;
|
|
241
|
+
inBase64 = true;
|
|
242
|
+
}
|
|
243
|
+
} else { // We decode base64.
|
|
244
|
+
if (!base64IMAPChars[buf[i]]) { // Base64 ended.
|
|
245
|
+
if (i == lastI && buf[i] == minusChar) { // "&-" -> "&"
|
|
246
|
+
res += "&";
|
|
247
|
+
} else {
|
|
248
|
+
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i), "ascii").replace(/,/g, '/');
|
|
249
|
+
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (buf[i] != minusChar) // Minus may be absorbed after base64.
|
|
253
|
+
i--;
|
|
254
|
+
|
|
255
|
+
lastI = i+1;
|
|
256
|
+
inBase64 = false;
|
|
257
|
+
base64Accum = '';
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (!inBase64) {
|
|
263
|
+
res += this.iconv.decode(buf.slice(lastI), "ascii"); // Write direct chars.
|
|
264
|
+
} else {
|
|
265
|
+
var b64str = base64Accum + this.iconv.decode(buf.slice(lastI), "ascii").replace(/,/g, '/');
|
|
266
|
+
|
|
267
|
+
var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars.
|
|
268
|
+
base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.
|
|
269
|
+
b64str = b64str.slice(0, canBeDecoded);
|
|
270
|
+
|
|
271
|
+
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
this.inBase64 = inBase64;
|
|
275
|
+
this.base64Accum = base64Accum;
|
|
276
|
+
|
|
277
|
+
return res;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
Utf7IMAPDecoder.prototype.end = function() {
|
|
281
|
+
var res = "";
|
|
282
|
+
if (this.inBase64 && this.base64Accum.length > 0)
|
|
283
|
+
res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");
|
|
284
|
+
|
|
285
|
+
this.inBase64 = false;
|
|
286
|
+
this.base64Accum = '';
|
|
287
|
+
return res;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var BOMChar = '\uFEFF';
|
|
4
|
+
|
|
5
|
+
exports.PrependBOM = PrependBOMWrapper
|
|
6
|
+
function PrependBOMWrapper(encoder, options) {
|
|
7
|
+
this.encoder = encoder;
|
|
8
|
+
this.addBOM = true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
PrependBOMWrapper.prototype.write = function(str) {
|
|
12
|
+
if (this.addBOM) {
|
|
13
|
+
str = BOMChar + str;
|
|
14
|
+
this.addBOM = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return this.encoder.write(str);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
PrependBOMWrapper.prototype.end = function() {
|
|
21
|
+
return this.encoder.end();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
//------------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
exports.StripBOM = StripBOMWrapper;
|
|
28
|
+
function StripBOMWrapper(decoder, options) {
|
|
29
|
+
this.decoder = decoder;
|
|
30
|
+
this.pass = false;
|
|
31
|
+
this.options = options || {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
StripBOMWrapper.prototype.write = function(buf) {
|
|
35
|
+
var res = this.decoder.write(buf);
|
|
36
|
+
if (this.pass || !res)
|
|
37
|
+
return res;
|
|
38
|
+
|
|
39
|
+
if (res[0] === BOMChar) {
|
|
40
|
+
res = res.slice(1);
|
|
41
|
+
if (typeof this.options.stripBOM === 'function')
|
|
42
|
+
this.options.stripBOM();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.pass = true;
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
StripBOMWrapper.prototype.end = function() {
|
|
50
|
+
return this.decoder.end();
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* REQUIREMENT: This definition is dependent on the @types/node definition.
|
|
5
|
+
* Install with `npm install @types/node --save-dev`
|
|
6
|
+
*--------------------------------------------------------------------------------------------*/
|
|
7
|
+
|
|
8
|
+
declare module 'iconv-lite' {
|
|
9
|
+
// Basic API
|
|
10
|
+
export function decode(buffer: Buffer, encoding: string, options?: Options): string;
|
|
11
|
+
|
|
12
|
+
export function encode(content: string, encoding: string, options?: Options): Buffer;
|
|
13
|
+
|
|
14
|
+
export function encodingExists(encoding: string): boolean;
|
|
15
|
+
|
|
16
|
+
// Stream API
|
|
17
|
+
export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
|
|
18
|
+
|
|
19
|
+
export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream;
|
|
20
|
+
|
|
21
|
+
// Low-level stream APIs
|
|
22
|
+
export function getEncoder(encoding: string, options?: Options): EncoderStream;
|
|
23
|
+
|
|
24
|
+
export function getDecoder(encoding: string, options?: Options): DecoderStream;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Options {
|
|
28
|
+
stripBOM?: boolean;
|
|
29
|
+
addBOM?: boolean;
|
|
30
|
+
defaultEncoding?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface EncoderStream {
|
|
34
|
+
write(str: string): Buffer;
|
|
35
|
+
end(): Buffer | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DecoderStream {
|
|
39
|
+
write(buf: Buffer): string;
|
|
40
|
+
end(): string | undefined;
|
|
41
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var Buffer = require("safer-buffer").Buffer;
|
|
4
|
+
|
|
5
|
+
var bomHandling = require("./bom-handling"),
|
|
6
|
+
iconv = module.exports;
|
|
7
|
+
|
|
8
|
+
// All codecs and aliases are kept here, keyed by encoding name/alias.
|
|
9
|
+
// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`.
|
|
10
|
+
iconv.encodings = null;
|
|
11
|
+
|
|
12
|
+
// Characters emitted in case of error.
|
|
13
|
+
iconv.defaultCharUnicode = '�';
|
|
14
|
+
iconv.defaultCharSingleByte = '?';
|
|
15
|
+
|
|
16
|
+
// Public API.
|
|
17
|
+
iconv.encode = function encode(str, encoding, options) {
|
|
18
|
+
str = "" + (str || ""); // Ensure string.
|
|
19
|
+
|
|
20
|
+
var encoder = iconv.getEncoder(encoding, options);
|
|
21
|
+
|
|
22
|
+
var res = encoder.write(str);
|
|
23
|
+
var trail = encoder.end();
|
|
24
|
+
|
|
25
|
+
return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
iconv.decode = function decode(buf, encoding, options) {
|
|
29
|
+
if (typeof buf === 'string') {
|
|
30
|
+
if (!iconv.skipDecodeWarning) {
|
|
31
|
+
console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding');
|
|
32
|
+
iconv.skipDecodeWarning = true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var decoder = iconv.getDecoder(encoding, options);
|
|
39
|
+
|
|
40
|
+
var res = decoder.write(buf);
|
|
41
|
+
var trail = decoder.end();
|
|
42
|
+
|
|
43
|
+
return trail ? (res + trail) : res;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
iconv.encodingExists = function encodingExists(enc) {
|
|
47
|
+
try {
|
|
48
|
+
iconv.getCodec(enc);
|
|
49
|
+
return true;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Legacy aliases to convert functions
|
|
56
|
+
iconv.toEncoding = iconv.encode;
|
|
57
|
+
iconv.fromEncoding = iconv.decode;
|
|
58
|
+
|
|
59
|
+
// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache.
|
|
60
|
+
iconv._codecDataCache = {};
|
|
61
|
+
iconv.getCodec = function getCodec(encoding) {
|
|
62
|
+
if (!iconv.encodings)
|
|
63
|
+
iconv.encodings = require("../encodings"); // Lazy load all encoding definitions.
|
|
64
|
+
|
|
65
|
+
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
|
66
|
+
var enc = iconv._canonicalizeEncoding(encoding);
|
|
67
|
+
|
|
68
|
+
// Traverse iconv.encodings to find actual codec.
|
|
69
|
+
var codecOptions = {};
|
|
70
|
+
while (true) {
|
|
71
|
+
var codec = iconv._codecDataCache[enc];
|
|
72
|
+
if (codec)
|
|
73
|
+
return codec;
|
|
74
|
+
|
|
75
|
+
var codecDef = iconv.encodings[enc];
|
|
76
|
+
|
|
77
|
+
switch (typeof codecDef) {
|
|
78
|
+
case "string": // Direct alias to other encoding.
|
|
79
|
+
enc = codecDef;
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case "object": // Alias with options. Can be layered.
|
|
83
|
+
for (var key in codecDef)
|
|
84
|
+
codecOptions[key] = codecDef[key];
|
|
85
|
+
|
|
86
|
+
if (!codecOptions.encodingName)
|
|
87
|
+
codecOptions.encodingName = enc;
|
|
88
|
+
|
|
89
|
+
enc = codecDef.type;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case "function": // Codec itself.
|
|
93
|
+
if (!codecOptions.encodingName)
|
|
94
|
+
codecOptions.encodingName = enc;
|
|
95
|
+
|
|
96
|
+
// The codec function must load all tables and return object with .encoder and .decoder methods.
|
|
97
|
+
// It'll be called only once (for each different options object).
|
|
98
|
+
codec = new codecDef(codecOptions, iconv);
|
|
99
|
+
|
|
100
|
+
iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later.
|
|
101
|
+
return codec;
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
iconv._canonicalizeEncoding = function(encoding) {
|
|
110
|
+
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
|
|
111
|
+
return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
iconv.getEncoder = function getEncoder(encoding, options) {
|
|
115
|
+
var codec = iconv.getCodec(encoding),
|
|
116
|
+
encoder = new codec.encoder(options, codec);
|
|
117
|
+
|
|
118
|
+
if (codec.bomAware && options && options.addBOM)
|
|
119
|
+
encoder = new bomHandling.PrependBOM(encoder, options);
|
|
120
|
+
|
|
121
|
+
return encoder;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
iconv.getDecoder = function getDecoder(encoding, options) {
|
|
125
|
+
var codec = iconv.getCodec(encoding),
|
|
126
|
+
decoder = new codec.decoder(options, codec);
|
|
127
|
+
|
|
128
|
+
if (codec.bomAware && !(options && options.stripBOM === false))
|
|
129
|
+
decoder = new bomHandling.StripBOM(decoder, options);
|
|
130
|
+
|
|
131
|
+
return decoder;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Streaming API
|
|
135
|
+
// NOTE: Streaming API naturally depends on 'stream' module from Node.js. Unfortunately in browser environments this module can add
|
|
136
|
+
// up to 100Kb to the output bundle. To avoid unnecessary code bloat, we don't enable Streaming API in browser by default.
|
|
137
|
+
// If you would like to enable it explicitly, please add the following code to your app:
|
|
138
|
+
// > iconv.enableStreamingAPI(require('stream'));
|
|
139
|
+
iconv.enableStreamingAPI = function enableStreamingAPI(stream_module) {
|
|
140
|
+
if (iconv.supportsStreams)
|
|
141
|
+
return;
|
|
142
|
+
|
|
143
|
+
// Dependency-inject stream module to create IconvLite stream classes.
|
|
144
|
+
var streams = require("./streams")(stream_module);
|
|
145
|
+
|
|
146
|
+
// Not public API yet, but expose the stream classes.
|
|
147
|
+
iconv.IconvLiteEncoderStream = streams.IconvLiteEncoderStream;
|
|
148
|
+
iconv.IconvLiteDecoderStream = streams.IconvLiteDecoderStream;
|
|
149
|
+
|
|
150
|
+
// Streaming API.
|
|
151
|
+
iconv.encodeStream = function encodeStream(encoding, options) {
|
|
152
|
+
return new iconv.IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
iconv.decodeStream = function decodeStream(encoding, options) {
|
|
156
|
+
return new iconv.IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
iconv.supportsStreams = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Enable Streaming API automatically if 'stream' module is available and non-empty (the majority of environments).
|
|
163
|
+
var stream_module;
|
|
164
|
+
try {
|
|
165
|
+
stream_module = require("stream");
|
|
166
|
+
} catch (e) {}
|
|
167
|
+
|
|
168
|
+
if (stream_module && stream_module.Transform) {
|
|
169
|
+
iconv.enableStreamingAPI(stream_module);
|
|
170
|
+
|
|
171
|
+
} else {
|
|
172
|
+
// In rare cases where 'stream' module is not available by default, throw a helpful exception.
|
|
173
|
+
iconv.encodeStream = iconv.decodeStream = function() {
|
|
174
|
+
throw new Error("iconv-lite Streaming API is not enabled. Use iconv.enableStreamingAPI(require('stream')); to enable it.");
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if ("Ā" != "\u0100") {
|
|
179
|
+
console.error("iconv-lite warning: js files use non-utf8 encoding. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info.");
|
|
180
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var Buffer = require("safer-buffer").Buffer;
|
|
4
|
+
|
|
5
|
+
// NOTE: Due to 'stream' module being pretty large (~100Kb, significant in browser environments),
|
|
6
|
+
// we opt to dependency-inject it instead of creating a hard dependency.
|
|
7
|
+
module.exports = function(stream_module) {
|
|
8
|
+
var Transform = stream_module.Transform;
|
|
9
|
+
|
|
10
|
+
// == Encoder stream =======================================================
|
|
11
|
+
|
|
12
|
+
function IconvLiteEncoderStream(conv, options) {
|
|
13
|
+
this.conv = conv;
|
|
14
|
+
options = options || {};
|
|
15
|
+
options.decodeStrings = false; // We accept only strings, so we don't need to decode them.
|
|
16
|
+
Transform.call(this, options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {
|
|
20
|
+
constructor: { value: IconvLiteEncoderStream }
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {
|
|
24
|
+
if (typeof chunk != 'string')
|
|
25
|
+
return done(new Error("Iconv encoding stream needs strings as its input."));
|
|
26
|
+
try {
|
|
27
|
+
var res = this.conv.write(chunk);
|
|
28
|
+
if (res && res.length) this.push(res);
|
|
29
|
+
done();
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
done(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
IconvLiteEncoderStream.prototype._flush = function(done) {
|
|
37
|
+
try {
|
|
38
|
+
var res = this.conv.end();
|
|
39
|
+
if (res && res.length) this.push(res);
|
|
40
|
+
done();
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
done(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
IconvLiteEncoderStream.prototype.collect = function(cb) {
|
|
48
|
+
var chunks = [];
|
|
49
|
+
this.on('error', cb);
|
|
50
|
+
this.on('data', function(chunk) { chunks.push(chunk); });
|
|
51
|
+
this.on('end', function() {
|
|
52
|
+
cb(null, Buffer.concat(chunks));
|
|
53
|
+
});
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
// == Decoder stream =======================================================
|
|
59
|
+
|
|
60
|
+
function IconvLiteDecoderStream(conv, options) {
|
|
61
|
+
this.conv = conv;
|
|
62
|
+
options = options || {};
|
|
63
|
+
options.encoding = this.encoding = 'utf8'; // We output strings.
|
|
64
|
+
Transform.call(this, options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {
|
|
68
|
+
constructor: { value: IconvLiteDecoderStream }
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
|
|
72
|
+
if (!Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array))
|
|
73
|
+
return done(new Error("Iconv decoding stream needs buffers as its input."));
|
|
74
|
+
try {
|
|
75
|
+
var res = this.conv.write(chunk);
|
|
76
|
+
if (res && res.length) this.push(res, this.encoding);
|
|
77
|
+
done();
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
done(e);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
IconvLiteDecoderStream.prototype._flush = function(done) {
|
|
85
|
+
try {
|
|
86
|
+
var res = this.conv.end();
|
|
87
|
+
if (res && res.length) this.push(res, this.encoding);
|
|
88
|
+
done();
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
done(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
IconvLiteDecoderStream.prototype.collect = function(cb) {
|
|
96
|
+
var res = '';
|
|
97
|
+
this.on('error', cb);
|
|
98
|
+
this.on('data', function(chunk) { res += chunk; });
|
|
99
|
+
this.on('end', function() {
|
|
100
|
+
cb(null, res);
|
|
101
|
+
});
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
IconvLiteEncoderStream: IconvLiteEncoderStream,
|
|
107
|
+
IconvLiteDecoderStream: IconvLiteDecoderStream,
|
|
108
|
+
};
|
|
109
|
+
};
|