lordceaser-baileys 3.4.2 → 3.4.6
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/WAProto/index.js +115856 -5
- package/WAProto/package.json +1 -0
- package/index.js +37 -21
- package/lib/Utils/crypto.js +118 -8
- package/lib/Utils/lt-hash.js +8 -3
- package/lib/package.json +3 -0
- package/node_modules/@protobufjs/aspromise/LICENSE +26 -0
- package/node_modules/@protobufjs/aspromise/README.md +13 -0
- package/node_modules/@protobufjs/aspromise/index.d.ts +13 -0
- package/node_modules/@protobufjs/aspromise/index.js +52 -0
- package/node_modules/@protobufjs/aspromise/package.json +21 -0
- package/node_modules/@protobufjs/aspromise/tests/index.js +130 -0
- package/node_modules/@protobufjs/base64/LICENSE +26 -0
- package/node_modules/@protobufjs/base64/README.md +19 -0
- package/node_modules/@protobufjs/base64/index.d.ts +32 -0
- package/node_modules/@protobufjs/base64/index.js +139 -0
- package/node_modules/@protobufjs/base64/package.json +21 -0
- package/node_modules/@protobufjs/base64/tests/index.js +46 -0
- package/node_modules/@protobufjs/codegen/LICENSE +26 -0
- package/node_modules/@protobufjs/codegen/README.md +49 -0
- package/node_modules/@protobufjs/codegen/index.d.ts +31 -0
- package/node_modules/@protobufjs/codegen/index.js +112 -0
- package/node_modules/@protobufjs/codegen/package.json +13 -0
- package/node_modules/@protobufjs/codegen/tests/index.js +13 -0
- package/node_modules/@protobufjs/eventemitter/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/eventemitter/LICENSE +26 -0
- package/node_modules/@protobufjs/eventemitter/README.md +22 -0
- package/node_modules/@protobufjs/eventemitter/index.d.ts +45 -0
- package/node_modules/@protobufjs/eventemitter/index.js +86 -0
- package/node_modules/@protobufjs/eventemitter/package.json +21 -0
- package/node_modules/@protobufjs/eventemitter/tests/index.js +83 -0
- package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/fetch/LICENSE +26 -0
- package/node_modules/@protobufjs/fetch/README.md +13 -0
- package/node_modules/@protobufjs/fetch/index.d.ts +56 -0
- package/node_modules/@protobufjs/fetch/index.js +112 -0
- package/node_modules/@protobufjs/fetch/package.json +27 -0
- package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
- package/node_modules/@protobufjs/fetch/tests/index.js +158 -0
- package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
- package/node_modules/@protobufjs/float/LICENSE +26 -0
- package/node_modules/@protobufjs/float/README.md +102 -0
- package/node_modules/@protobufjs/float/bench/index.js +87 -0
- package/node_modules/@protobufjs/float/bench/suite.js +46 -0
- package/node_modules/@protobufjs/float/index.d.ts +83 -0
- package/node_modules/@protobufjs/float/index.js +335 -0
- package/node_modules/@protobufjs/float/package.json +26 -0
- package/node_modules/@protobufjs/float/tests/index.js +100 -0
- package/node_modules/@protobufjs/path/LICENSE +26 -0
- package/node_modules/@protobufjs/path/README.md +19 -0
- package/node_modules/@protobufjs/path/index.d.ts +22 -0
- package/node_modules/@protobufjs/path/index.js +65 -0
- package/node_modules/@protobufjs/path/package.json +21 -0
- package/node_modules/@protobufjs/path/tests/index.js +60 -0
- package/node_modules/@protobufjs/pool/.npmignore +3 -0
- package/node_modules/@protobufjs/pool/LICENSE +26 -0
- package/node_modules/@protobufjs/pool/README.md +13 -0
- package/node_modules/@protobufjs/pool/index.d.ts +32 -0
- package/node_modules/@protobufjs/pool/index.js +48 -0
- package/node_modules/@protobufjs/pool/package.json +21 -0
- package/node_modules/@protobufjs/pool/tests/index.js +33 -0
- package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/utf8/LICENSE +26 -0
- package/node_modules/@protobufjs/utf8/README.md +20 -0
- package/node_modules/@protobufjs/utf8/index.d.ts +24 -0
- package/node_modules/@protobufjs/utf8/index.js +115 -0
- package/node_modules/@protobufjs/utf8/package.json +21 -0
- package/node_modules/@protobufjs/utf8/tests/data/surrogate_pair_bug.txt +207 -0
- package/node_modules/@protobufjs/utf8/tests/data/utf8.txt +216 -0
- package/node_modules/@protobufjs/utf8/tests/index.js +79 -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 +2712 -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/curve25519-js/.prettierrc +6 -0
- package/node_modules/curve25519-js/LICENSE +19 -0
- package/node_modules/curve25519-js/README.md +111 -0
- package/node_modules/curve25519-js/lib/index.d.ts +69 -0
- package/node_modules/curve25519-js/lib/index.js +1669 -0
- package/node_modules/curve25519-js/package.json +34 -0
- package/node_modules/curve25519-js/tsconfig.json +20 -0
- package/node_modules/curve25519-js/tslint.json +10 -0
- package/node_modules/libsignal/LICENSE +621 -0
- package/node_modules/libsignal/README.md +64 -0
- package/node_modules/libsignal/index.d.ts +55 -0
- package/node_modules/libsignal/index.js +10 -0
- package/node_modules/libsignal/package.json +34 -0
- package/node_modules/libsignal/src/.eslintrc.json +31 -0
- package/node_modules/libsignal/src/WhisperTextProtocol.js +933 -0
- package/node_modules/libsignal/src/base_key_type.js +7 -0
- package/node_modules/libsignal/src/chain_type.js +6 -0
- package/node_modules/libsignal/src/crypto.d.ts +19 -0
- package/node_modules/libsignal/src/crypto.js +98 -0
- package/node_modules/libsignal/src/curve.d.ts +22 -0
- package/node_modules/libsignal/src/curve.js +142 -0
- package/node_modules/libsignal/src/errors.js +33 -0
- package/node_modules/libsignal/src/keyhelper.js +45 -0
- package/node_modules/libsignal/src/numeric_fingerprint.js +72 -0
- package/node_modules/libsignal/src/protobufs.js +10 -0
- package/node_modules/libsignal/src/protocol_address.js +40 -0
- package/node_modules/libsignal/src/queue_job.js +69 -0
- package/node_modules/libsignal/src/session_builder.js +164 -0
- package/node_modules/libsignal/src/session_cipher.js +336 -0
- package/node_modules/libsignal/src/session_record.js +316 -0
- package/node_modules/long/LICENSE +202 -0
- package/node_modules/long/README.md +286 -0
- package/node_modules/long/index.d.ts +2 -0
- package/node_modules/long/index.js +1581 -0
- package/node_modules/long/package.json +58 -0
- package/node_modules/long/types.d.ts +474 -0
- package/node_modules/long/umd/index.d.ts +3 -0
- package/node_modules/long/umd/index.js +1622 -0
- package/node_modules/long/umd/package.json +3 -0
- package/node_modules/long/umd/types.d.ts +474 -0
- package/node_modules/protobufjs/LICENSE +39 -0
- package/node_modules/protobufjs/README.md +727 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +8094 -0
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/light/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2811 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/dist/protobuf.js +9921 -0
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/ext/debug/README.md +4 -0
- package/node_modules/protobufjs/ext/debug/index.js +71 -0
- package/node_modules/protobufjs/ext/descriptor/README.md +72 -0
- package/node_modules/protobufjs/ext/descriptor/index.d.ts +195 -0
- package/node_modules/protobufjs/ext/descriptor/index.js +1186 -0
- package/node_modules/protobufjs/ext/descriptor/test.js +54 -0
- package/node_modules/protobufjs/google/LICENSE +27 -0
- package/node_modules/protobufjs/google/README.md +1 -0
- package/node_modules/protobufjs/google/api/annotations.json +83 -0
- package/node_modules/protobufjs/google/api/annotations.proto +11 -0
- package/node_modules/protobufjs/google/api/http.json +86 -0
- package/node_modules/protobufjs/google/api/http.proto +31 -0
- package/node_modules/protobufjs/google/protobuf/api.json +118 -0
- package/node_modules/protobufjs/google/protobuf/api.proto +34 -0
- package/node_modules/protobufjs/google/protobuf/descriptor.json +1382 -0
- package/node_modules/protobufjs/google/protobuf/descriptor.proto +535 -0
- package/node_modules/protobufjs/google/protobuf/source_context.json +20 -0
- package/node_modules/protobufjs/google/protobuf/source_context.proto +7 -0
- package/node_modules/protobufjs/google/protobuf/type.json +202 -0
- package/node_modules/protobufjs/google/protobuf/type.proto +89 -0
- package/node_modules/protobufjs/index.d.ts +2832 -0
- package/node_modules/protobufjs/index.js +4 -0
- package/node_modules/protobufjs/light.d.ts +2 -0
- package/node_modules/protobufjs/light.js +4 -0
- package/node_modules/protobufjs/minimal.d.ts +2 -0
- package/node_modules/protobufjs/minimal.js +4 -0
- package/node_modules/protobufjs/package.json +119 -0
- package/node_modules/protobufjs/scripts/postinstall.js +32 -0
- package/node_modules/protobufjs/src/common.js +399 -0
- package/node_modules/protobufjs/src/converter.js +318 -0
- package/node_modules/protobufjs/src/decoder.js +164 -0
- package/node_modules/protobufjs/src/encoder.js +103 -0
- package/node_modules/protobufjs/src/enum.js +226 -0
- package/node_modules/protobufjs/src/field.js +453 -0
- package/node_modules/protobufjs/src/index-light.js +104 -0
- package/node_modules/protobufjs/src/index-minimal.js +36 -0
- package/node_modules/protobufjs/src/index.js +12 -0
- package/node_modules/protobufjs/src/mapfield.js +126 -0
- package/node_modules/protobufjs/src/message.js +143 -0
- package/node_modules/protobufjs/src/method.js +160 -0
- package/node_modules/protobufjs/src/namespace.js +558 -0
- package/node_modules/protobufjs/src/object.js +382 -0
- package/node_modules/protobufjs/src/oneof.js +222 -0
- package/node_modules/protobufjs/src/parse.js +992 -0
- package/node_modules/protobufjs/src/reader.js +446 -0
- package/node_modules/protobufjs/src/reader_buffer.js +51 -0
- package/node_modules/protobufjs/src/root.js +412 -0
- package/node_modules/protobufjs/src/roots.js +18 -0
- package/node_modules/protobufjs/src/rpc/service.js +142 -0
- package/node_modules/protobufjs/src/rpc.js +36 -0
- package/node_modules/protobufjs/src/service.js +193 -0
- package/node_modules/protobufjs/src/tokenize.js +416 -0
- package/node_modules/protobufjs/src/type.js +632 -0
- package/node_modules/protobufjs/src/types.js +196 -0
- package/node_modules/protobufjs/src/typescript.jsdoc +15 -0
- package/node_modules/protobufjs/src/util/fs.js +11 -0
- package/node_modules/protobufjs/src/util/longbits.js +200 -0
- package/node_modules/protobufjs/src/util/minimal.js +491 -0
- package/node_modules/protobufjs/src/util/patterns.js +7 -0
- package/node_modules/protobufjs/src/util.js +230 -0
- package/node_modules/protobufjs/src/verifier.js +180 -0
- package/node_modules/protobufjs/src/wrappers.js +111 -0
- package/node_modules/protobufjs/src/writer.js +467 -0
- package/node_modules/protobufjs/src/writer_buffer.js +85 -0
- package/node_modules/protobufjs/tsconfig.json +8 -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/package.json +65 -29
- package/WAProto/_orig.js +0 -115856
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@protobufjs/path
|
|
2
|
+
================
|
|
3
|
+
[](https://www.npmjs.com/package/@protobufjs/path)
|
|
4
|
+
|
|
5
|
+
A minimal path module to resolve Unix, Windows and URL paths alike.
|
|
6
|
+
|
|
7
|
+
API
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
* **path.isAbsolute(path: `string`): `boolean`**<br />
|
|
11
|
+
Tests if the specified path is absolute.
|
|
12
|
+
|
|
13
|
+
* **path.normalize(path: `string`): `string`**<br />
|
|
14
|
+
Normalizes the specified path.
|
|
15
|
+
|
|
16
|
+
* **path.resolve(originPath: `string`, includePath: `string`, [alreadyNormalized=false: `boolean`]): `string`**<br />
|
|
17
|
+
Resolves the specified include path against the specified origin path.
|
|
18
|
+
|
|
19
|
+
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests if the specified path is absolute.
|
|
3
|
+
* @param {string} path Path to test
|
|
4
|
+
* @returns {boolean} `true` if path is absolute
|
|
5
|
+
*/
|
|
6
|
+
export function isAbsolute(path: string): boolean;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes the specified path.
|
|
10
|
+
* @param {string} path Path to normalize
|
|
11
|
+
* @returns {string} Normalized path
|
|
12
|
+
*/
|
|
13
|
+
export function normalize(path: string): string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the specified include path against the specified origin path.
|
|
17
|
+
* @param {string} originPath Path to the origin file
|
|
18
|
+
* @param {string} includePath Include path relative to origin path
|
|
19
|
+
* @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized
|
|
20
|
+
* @returns {string} Path to the include file
|
|
21
|
+
*/
|
|
22
|
+
export function resolve(originPath: string, includePath: string, alreadyNormalized?: boolean): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A minimal path module to resolve Unix, Windows and URL paths alike.
|
|
5
|
+
* @memberof util
|
|
6
|
+
* @namespace
|
|
7
|
+
*/
|
|
8
|
+
var path = exports;
|
|
9
|
+
|
|
10
|
+
var isAbsolute =
|
|
11
|
+
/**
|
|
12
|
+
* Tests if the specified path is absolute.
|
|
13
|
+
* @param {string} path Path to test
|
|
14
|
+
* @returns {boolean} `true` if path is absolute
|
|
15
|
+
*/
|
|
16
|
+
path.isAbsolute = function isAbsolute(path) {
|
|
17
|
+
return /^(?:\/|\w+:)/.test(path);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var normalize =
|
|
21
|
+
/**
|
|
22
|
+
* Normalizes the specified path.
|
|
23
|
+
* @param {string} path Path to normalize
|
|
24
|
+
* @returns {string} Normalized path
|
|
25
|
+
*/
|
|
26
|
+
path.normalize = function normalize(path) {
|
|
27
|
+
path = path.replace(/\\/g, "/")
|
|
28
|
+
.replace(/\/{2,}/g, "/");
|
|
29
|
+
var parts = path.split("/"),
|
|
30
|
+
absolute = isAbsolute(path),
|
|
31
|
+
prefix = "";
|
|
32
|
+
if (absolute)
|
|
33
|
+
prefix = parts.shift() + "/";
|
|
34
|
+
for (var i = 0; i < parts.length;) {
|
|
35
|
+
if (parts[i] === "..") {
|
|
36
|
+
if (i > 0 && parts[i - 1] !== "..")
|
|
37
|
+
parts.splice(--i, 2);
|
|
38
|
+
else if (absolute)
|
|
39
|
+
parts.splice(i, 1);
|
|
40
|
+
else
|
|
41
|
+
++i;
|
|
42
|
+
} else if (parts[i] === ".")
|
|
43
|
+
parts.splice(i, 1);
|
|
44
|
+
else
|
|
45
|
+
++i;
|
|
46
|
+
}
|
|
47
|
+
return prefix + parts.join("/");
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the specified include path against the specified origin path.
|
|
52
|
+
* @param {string} originPath Path to the origin file
|
|
53
|
+
* @param {string} includePath Include path relative to origin path
|
|
54
|
+
* @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized
|
|
55
|
+
* @returns {string} Path to the include file
|
|
56
|
+
*/
|
|
57
|
+
path.resolve = function resolve(originPath, includePath, alreadyNormalized) {
|
|
58
|
+
if (!alreadyNormalized)
|
|
59
|
+
includePath = normalize(includePath);
|
|
60
|
+
if (isAbsolute(includePath))
|
|
61
|
+
return includePath;
|
|
62
|
+
if (!alreadyNormalized)
|
|
63
|
+
originPath = normalize(originPath);
|
|
64
|
+
return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath;
|
|
65
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@protobufjs/path",
|
|
3
|
+
"description": "A minimal path module to resolve Unix, Windows and URL paths alike.",
|
|
4
|
+
"version": "1.1.2",
|
|
5
|
+
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/dcodeIO/protobuf.js.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSD-3-Clause",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"istanbul": "^0.4.5",
|
|
15
|
+
"tape": "^4.6.3"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "tape tests/*.js",
|
|
19
|
+
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var tape = require("tape");
|
|
2
|
+
|
|
3
|
+
var path = require("..");
|
|
4
|
+
|
|
5
|
+
tape.test("path", function(test) {
|
|
6
|
+
|
|
7
|
+
test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");
|
|
8
|
+
test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");
|
|
9
|
+
|
|
10
|
+
test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");
|
|
11
|
+
test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");
|
|
12
|
+
|
|
13
|
+
var paths = [
|
|
14
|
+
{
|
|
15
|
+
actual: "X:\\some\\..\\.\\path\\\\file.js",
|
|
16
|
+
normal: "X:/path/file.js",
|
|
17
|
+
resolve: {
|
|
18
|
+
origin: "X:/path/origin.js",
|
|
19
|
+
expected: "X:/path/file.js"
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
actual: "some\\..\\.\\path\\\\file.js",
|
|
23
|
+
normal: "path/file.js",
|
|
24
|
+
resolve: {
|
|
25
|
+
origin: "X:/path/origin.js",
|
|
26
|
+
expected: "X:/path/path/file.js"
|
|
27
|
+
}
|
|
28
|
+
}, {
|
|
29
|
+
actual: "/some/.././path//file.js",
|
|
30
|
+
normal: "/path/file.js",
|
|
31
|
+
resolve: {
|
|
32
|
+
origin: "/path/origin.js",
|
|
33
|
+
expected: "/path/file.js"
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
actual: "some/.././path//file.js",
|
|
37
|
+
normal: "path/file.js",
|
|
38
|
+
resolve: {
|
|
39
|
+
origin: "",
|
|
40
|
+
expected: "path/file.js"
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
actual: ".././path//file.js",
|
|
44
|
+
normal: "../path/file.js"
|
|
45
|
+
}, {
|
|
46
|
+
actual: "/.././path//file.js",
|
|
47
|
+
normal: "/path/file.js"
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
paths.forEach(function(p) {
|
|
52
|
+
test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);
|
|
53
|
+
if (p.resolve) {
|
|
54
|
+
test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);
|
|
55
|
+
test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test.end();
|
|
60
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2016, Daniel Wirtz All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name of its author, nor the names of its contributors
|
|
13
|
+
may be used to endorse or promote products derived from this software
|
|
14
|
+
without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
20
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
21
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
22
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@protobufjs/pool
|
|
2
|
+
================
|
|
3
|
+
[](https://www.npmjs.com/package/@protobufjs/pool)
|
|
4
|
+
|
|
5
|
+
A general purpose buffer pool.
|
|
6
|
+
|
|
7
|
+
API
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
* **pool(alloc: `function(size: number): Uint8Array`, slice: `function(this: Uint8Array, start: number, end: number): Uint8Array`, [size=8192: `number`]): `function(size: number): Uint8Array`**<br />
|
|
11
|
+
Creates a pooled allocator.
|
|
12
|
+
|
|
13
|
+
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export = pool;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An allocator as used by {@link util.pool}.
|
|
5
|
+
* @typedef PoolAllocator
|
|
6
|
+
* @type {function}
|
|
7
|
+
* @param {number} size Buffer size
|
|
8
|
+
* @returns {Uint8Array} Buffer
|
|
9
|
+
*/
|
|
10
|
+
type PoolAllocator = (size: number) => Uint8Array;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A slicer as used by {@link util.pool}.
|
|
14
|
+
* @typedef PoolSlicer
|
|
15
|
+
* @type {function}
|
|
16
|
+
* @param {number} start Start offset
|
|
17
|
+
* @param {number} end End offset
|
|
18
|
+
* @returns {Uint8Array} Buffer slice
|
|
19
|
+
* @this {Uint8Array}
|
|
20
|
+
*/
|
|
21
|
+
type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A general purpose buffer pool.
|
|
25
|
+
* @memberof util
|
|
26
|
+
* @function
|
|
27
|
+
* @param {PoolAllocator} alloc Allocator
|
|
28
|
+
* @param {PoolSlicer} slice Slicer
|
|
29
|
+
* @param {number} [size=8192] Slab size
|
|
30
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
31
|
+
*/
|
|
32
|
+
declare function pool(alloc: PoolAllocator, slice: PoolSlicer, size?: number): PoolAllocator;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = pool;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An allocator as used by {@link util.pool}.
|
|
6
|
+
* @typedef PoolAllocator
|
|
7
|
+
* @type {function}
|
|
8
|
+
* @param {number} size Buffer size
|
|
9
|
+
* @returns {Uint8Array} Buffer
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A slicer as used by {@link util.pool}.
|
|
14
|
+
* @typedef PoolSlicer
|
|
15
|
+
* @type {function}
|
|
16
|
+
* @param {number} start Start offset
|
|
17
|
+
* @param {number} end End offset
|
|
18
|
+
* @returns {Uint8Array} Buffer slice
|
|
19
|
+
* @this {Uint8Array}
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A general purpose buffer pool.
|
|
24
|
+
* @memberof util
|
|
25
|
+
* @function
|
|
26
|
+
* @param {PoolAllocator} alloc Allocator
|
|
27
|
+
* @param {PoolSlicer} slice Slicer
|
|
28
|
+
* @param {number} [size=8192] Slab size
|
|
29
|
+
* @returns {PoolAllocator} Pooled allocator
|
|
30
|
+
*/
|
|
31
|
+
function pool(alloc, slice, size) {
|
|
32
|
+
var SIZE = size || 8192;
|
|
33
|
+
var MAX = SIZE >>> 1;
|
|
34
|
+
var slab = null;
|
|
35
|
+
var offset = SIZE;
|
|
36
|
+
return function pool_alloc(size) {
|
|
37
|
+
if (size < 1 || size > MAX)
|
|
38
|
+
return alloc(size);
|
|
39
|
+
if (offset + size > SIZE) {
|
|
40
|
+
slab = alloc(SIZE);
|
|
41
|
+
offset = 0;
|
|
42
|
+
}
|
|
43
|
+
var buf = slice.call(slab, offset, offset += size);
|
|
44
|
+
if (offset & 7) // align to 32 bit
|
|
45
|
+
offset = (offset | 7) + 1;
|
|
46
|
+
return buf;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@protobufjs/pool",
|
|
3
|
+
"description": "A general purpose buffer pool.",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/dcodeIO/protobuf.js.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSD-3-Clause",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"istanbul": "^0.4.5",
|
|
15
|
+
"tape": "^4.6.3"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "tape tests/*.js",
|
|
19
|
+
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var tape = require("tape");
|
|
2
|
+
|
|
3
|
+
var pool = require("..");
|
|
4
|
+
|
|
5
|
+
if (typeof Uint8Array !== "undefined")
|
|
6
|
+
tape.test("pool", function(test) {
|
|
7
|
+
|
|
8
|
+
var alloc = pool(function(size) { return new Uint8Array(size); }, Uint8Array.prototype.subarray);
|
|
9
|
+
|
|
10
|
+
var buf1 = alloc(0);
|
|
11
|
+
test.equal(buf1.length, 0, "should allocate a buffer of size 0");
|
|
12
|
+
|
|
13
|
+
var buf2 = alloc(1);
|
|
14
|
+
test.equal(buf2.length, 1, "should allocate a buffer of size 1 (initializes slab)");
|
|
15
|
+
|
|
16
|
+
test.notEqual(buf2.buffer, buf1.buffer, "should not reference the same backing buffer if previous buffer had size 0");
|
|
17
|
+
test.equal(buf2.byteOffset, 0, "should allocate at byteOffset 0 when using a new slab");
|
|
18
|
+
|
|
19
|
+
buf1 = alloc(1);
|
|
20
|
+
test.equal(buf1.buffer, buf2.buffer, "should reference the same backing buffer when allocating a chunk fitting into the slab");
|
|
21
|
+
test.equal(buf1.byteOffset, 8, "should align slices to 32 bit and this allocate at byteOffset 8");
|
|
22
|
+
|
|
23
|
+
var buf3 = alloc(4097);
|
|
24
|
+
test.notEqual(buf3.buffer, buf2.buffer, "should not reference the same backing buffer when allocating a buffer larger than half the backing buffer's size");
|
|
25
|
+
|
|
26
|
+
buf2 = alloc(4096);
|
|
27
|
+
test.equal(buf2.buffer, buf1.buffer, "should reference the same backing buffer when allocating a buffer smaller or equal than half the backing buffer's size");
|
|
28
|
+
|
|
29
|
+
buf1 = alloc(4096);
|
|
30
|
+
test.notEqual(buf1.buffer, buf2.buffer, "should not reference the same backing buffer when the slab is exhausted (initializes new slab)");
|
|
31
|
+
|
|
32
|
+
test.end();
|
|
33
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.1.2](https://github.com/protobufjs/protobuf.js/compare/utf8-v1.1.1...utf8-v1.1.2) (2026-07-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Performance Improvements
|
|
7
|
+
|
|
8
|
+
* Batch String.fromCharCode in @protobufjs/utf8 read ([#2355](https://github.com/protobufjs/protobuf.js/issues/2355)) ([d1ae3ce](https://github.com/protobufjs/protobuf.js/commit/d1ae3ce46370254ada0f3db689506a9139c8d1ee))
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2016, Daniel Wirtz All rights reserved.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name of its author, nor the names of its contributors
|
|
13
|
+
may be used to endorse or promote products derived from this software
|
|
14
|
+
without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
20
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
21
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
22
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@protobufjs/utf8
|
|
2
|
+
================
|
|
3
|
+
[](https://www.npmjs.com/package/@protobufjs/utf8)
|
|
4
|
+
|
|
5
|
+
A minimal UTF8 implementation for number arrays.
|
|
6
|
+
|
|
7
|
+
API
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
* **utf8.length(string: `string`): `number`**<br />
|
|
11
|
+
Calculates the UTF8 byte length of a string.
|
|
12
|
+
|
|
13
|
+
* **utf8.read(buffer: `Uint8Array`, start: `number`, end: `number`): `string`**<br />
|
|
14
|
+
Reads UTF8 bytes as a string.
|
|
15
|
+
|
|
16
|
+
* **utf8.write(string: `string`, buffer: `Uint8Array`, offset: `number`): `number`**<br />
|
|
17
|
+
Writes a string as UTF8 bytes.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the UTF8 byte length of a string.
|
|
3
|
+
* @param {string} string String
|
|
4
|
+
* @returns {number} Byte length
|
|
5
|
+
*/
|
|
6
|
+
export function length(string: string): number;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reads UTF8 bytes as a string.
|
|
10
|
+
* @param {Uint8Array} buffer Source buffer
|
|
11
|
+
* @param {number} start Source start
|
|
12
|
+
* @param {number} end Source end
|
|
13
|
+
* @returns {string} String read
|
|
14
|
+
*/
|
|
15
|
+
export function read(buffer: Uint8Array, start: number, end: number): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Writes a string as UTF8 bytes.
|
|
19
|
+
* @param {string} string Source string
|
|
20
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
21
|
+
* @param {number} offset Destination offset
|
|
22
|
+
* @returns {number} Bytes written
|
|
23
|
+
*/
|
|
24
|
+
export function write(string: string, buffer: Uint8Array, offset: number): number;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A minimal UTF8 implementation for number arrays.
|
|
5
|
+
* @memberof util
|
|
6
|
+
* @namespace
|
|
7
|
+
*/
|
|
8
|
+
var utf8 = exports,
|
|
9
|
+
replacementCharCode = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Calculates the UTF8 byte length of a string.
|
|
13
|
+
* @param {string} string String
|
|
14
|
+
* @returns {number} Byte length
|
|
15
|
+
*/
|
|
16
|
+
utf8.length = function utf8_length(string) {
|
|
17
|
+
var len = 0,
|
|
18
|
+
c = 0;
|
|
19
|
+
for (var i = 0; i < string.length; ++i) {
|
|
20
|
+
c = string.charCodeAt(i);
|
|
21
|
+
if (c < 128)
|
|
22
|
+
len += 1;
|
|
23
|
+
else if (c < 2048)
|
|
24
|
+
len += 2;
|
|
25
|
+
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
|
|
26
|
+
++i;
|
|
27
|
+
len += 4;
|
|
28
|
+
} else
|
|
29
|
+
len += 3;
|
|
30
|
+
}
|
|
31
|
+
return len;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Reads UTF8 bytes as a string.
|
|
36
|
+
* @param {Uint8Array} buffer Source buffer
|
|
37
|
+
* @param {number} start Source start
|
|
38
|
+
* @param {number} end Source end
|
|
39
|
+
* @returns {string} String read
|
|
40
|
+
*/
|
|
41
|
+
utf8.read = function utf8_read(buffer, start, end) {
|
|
42
|
+
if (end - start < 1)
|
|
43
|
+
return "";
|
|
44
|
+
// Batch code units and flush via String.fromCharCode.apply in 8192-unit
|
|
45
|
+
// chunks to avoid the per-character ConsString buildup of `str += ...`.
|
|
46
|
+
var parts = null,
|
|
47
|
+
chunk = [],
|
|
48
|
+
i = 0, // chunk write index
|
|
49
|
+
t, t2, c2, c3;
|
|
50
|
+
while (start < end) {
|
|
51
|
+
t = buffer[start++];
|
|
52
|
+
if (t <= 0x7F) {
|
|
53
|
+
chunk[i++] = t;
|
|
54
|
+
} else if (t >= 0xC0 && t < 0xE0) {
|
|
55
|
+
c2 = (t & 0x1F) << 6 | buffer[start++] & 0x3F;
|
|
56
|
+
chunk[i++] = c2 >= 0x80 ? c2 : replacementCharCode;
|
|
57
|
+
} else if (t >= 0xE0 && t < 0xF0) {
|
|
58
|
+
c3 = (t & 0xF) << 12 | (buffer[start++] & 0x3F) << 6 | buffer[start++] & 0x3F;
|
|
59
|
+
chunk[i++] = c3 >= 0x800 ? c3 : replacementCharCode;
|
|
60
|
+
} else if (t >= 0xF0) {
|
|
61
|
+
t2 = (t & 7) << 18 | (buffer[start++] & 0x3F) << 12 | (buffer[start++] & 0x3F) << 6 | buffer[start++] & 0x3F;
|
|
62
|
+
if (t2 < 0x10000 || t2 > 0x10FFFF)
|
|
63
|
+
chunk[i++] = replacementCharCode;
|
|
64
|
+
else {
|
|
65
|
+
t2 -= 0x10000;
|
|
66
|
+
chunk[i++] = 0xD800 + (t2 >> 10);
|
|
67
|
+
chunk[i++] = 0xDC00 + (t2 & 0x3FF);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (i > 8191) {
|
|
71
|
+
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
72
|
+
i = 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (parts) {
|
|
76
|
+
if (i)
|
|
77
|
+
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
|
|
78
|
+
return parts.join("");
|
|
79
|
+
}
|
|
80
|
+
return String.fromCharCode.apply(String, chunk.slice(0, i));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Writes a string as UTF8 bytes.
|
|
85
|
+
* @param {string} string Source string
|
|
86
|
+
* @param {Uint8Array} buffer Destination buffer
|
|
87
|
+
* @param {number} offset Destination offset
|
|
88
|
+
* @returns {number} Bytes written
|
|
89
|
+
*/
|
|
90
|
+
utf8.write = function utf8_write(string, buffer, offset) {
|
|
91
|
+
var start = offset,
|
|
92
|
+
c1, // character 1
|
|
93
|
+
c2; // character 2
|
|
94
|
+
for (var i = 0; i < string.length; ++i) {
|
|
95
|
+
c1 = string.charCodeAt(i);
|
|
96
|
+
if (c1 < 128) {
|
|
97
|
+
buffer[offset++] = c1;
|
|
98
|
+
} else if (c1 < 2048) {
|
|
99
|
+
buffer[offset++] = c1 >> 6 | 192;
|
|
100
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
101
|
+
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
|
|
102
|
+
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
|
|
103
|
+
++i;
|
|
104
|
+
buffer[offset++] = c1 >> 18 | 240;
|
|
105
|
+
buffer[offset++] = c1 >> 12 & 63 | 128;
|
|
106
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
107
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
108
|
+
} else {
|
|
109
|
+
buffer[offset++] = c1 >> 12 | 224;
|
|
110
|
+
buffer[offset++] = c1 >> 6 & 63 | 128;
|
|
111
|
+
buffer[offset++] = c1 & 63 | 128;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return offset - start;
|
|
115
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@protobufjs/utf8",
|
|
3
|
+
"description": "A minimal UTF8 implementation for number arrays.",
|
|
4
|
+
"version": "1.1.2",
|
|
5
|
+
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/protobufjs/protobuf.js.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSD-3-Clause",
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"types": "index.d.ts",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"istanbul": "^0.4.5",
|
|
15
|
+
"tape": "^5.0.0"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "tape tests/*.js",
|
|
19
|
+
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
|
|
20
|
+
}
|
|
21
|
+
}
|