diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@protobufjs/fetch | |
pain
Diffstat (limited to 'frontend-old/node_modules/@protobufjs/fetch')
6 files changed, 251 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@protobufjs/fetch/LICENSE b/frontend-old/node_modules/@protobufjs/fetch/LICENSE new file mode 100644 index 0000000..2a2d560 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/frontend-old/node_modules/@protobufjs/fetch/README.md b/frontend-old/node_modules/@protobufjs/fetch/README.md new file mode 100644 index 0000000..11088a0 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/README.md @@ -0,0 +1,13 @@ +@protobufjs/fetch
+=================
+[](https://www.npmjs.com/package/@protobufjs/fetch)
+
+Fetches the contents of a file accross node and browsers.
+
+API
+---
+
+* **fetch(path: `string`, [options: { binary: boolean } ], [callback: `function(error: ?Error, [contents: string])`]): `Promise<string|Uint8Array>|undefined`**
+ Fetches the contents of a file.
+
+**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
diff --git a/frontend-old/node_modules/@protobufjs/fetch/index.d.ts b/frontend-old/node_modules/@protobufjs/fetch/index.d.ts new file mode 100644 index 0000000..77cf9f3 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/index.d.ts @@ -0,0 +1,56 @@ +export = fetch;
+
+/**
+ * Node-style callback as used by {@link util.fetch}.
+ * @typedef FetchCallback
+ * @type {function}
+ * @param {?Error} error Error, if any, otherwise `null`
+ * @param {string} [contents] File contents, if there hasn't been an error
+ * @returns {undefined}
+ */
+type FetchCallback = (error: Error, contents?: string) => void;
+
+/**
+ * Options as used by {@link util.fetch}.
+ * @typedef FetchOptions
+ * @type {Object}
+ * @property {boolean} [binary=false] Whether expecting a binary response
+ * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
+ */
+
+interface FetchOptions {
+ binary?: boolean;
+ xhr?: boolean
+}
+
+/**
+ * Fetches the contents of a file.
+ * @memberof util
+ * @param {string} filename File path or url
+ * @param {FetchOptions} options Fetch options
+ * @param {FetchCallback} callback Callback function
+ * @returns {undefined}
+ */
+declare function fetch(filename: string, options: FetchOptions, callback: FetchCallback): void;
+
+/**
+ * Fetches the contents of a file.
+ * @name util.fetch
+ * @function
+ * @param {string} path File path or url
+ * @param {FetchCallback} callback Callback function
+ * @returns {undefined}
+ * @variation 2
+ */
+declare function fetch(path: string, callback: FetchCallback): void;
+
+/**
+ * Fetches the contents of a file.
+ * @name util.fetch
+ * @function
+ * @param {string} path File path or url
+ * @param {FetchOptions} [options] Fetch options
+ * @returns {Promise<string|Uint8Array>} Promise
+ * @variation 3
+ */
+declare function fetch(path: string, options?: FetchOptions): Promise<(string|Uint8Array)>;
diff --git a/frontend-old/node_modules/@protobufjs/fetch/index.js b/frontend-old/node_modules/@protobufjs/fetch/index.js new file mode 100644 index 0000000..f2766f5 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/index.js @@ -0,0 +1,115 @@ +"use strict";
+module.exports = fetch;
+
+var asPromise = require("@protobufjs/aspromise"),
+ inquire = require("@protobufjs/inquire");
+
+var fs = inquire("fs");
+
+/**
+ * Node-style callback as used by {@link util.fetch}.
+ * @typedef FetchCallback
+ * @type {function}
+ * @param {?Error} error Error, if any, otherwise `null`
+ * @param {string} [contents] File contents, if there hasn't been an error
+ * @returns {undefined}
+ */
+
+/**
+ * Options as used by {@link util.fetch}.
+ * @typedef FetchOptions
+ * @type {Object}
+ * @property {boolean} [binary=false] Whether expecting a binary response
+ * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
+ */
+
+/**
+ * Fetches the contents of a file.
+ * @memberof util
+ * @param {string} filename File path or url
+ * @param {FetchOptions} options Fetch options
+ * @param {FetchCallback} callback Callback function
+ * @returns {undefined}
+ */
+function fetch(filename, options, callback) {
+ if (typeof options === "function") {
+ callback = options;
+ options = {};
+ } else if (!options)
+ options = {};
+
+ if (!callback)
+ return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this
+
+ // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found.
+ if (!options.xhr && fs && fs.readFile)
+ return fs.readFile(filename, function fetchReadFileCallback(err, contents) {
+ return err && typeof XMLHttpRequest !== "undefined"
+ ? fetch.xhr(filename, options, callback)
+ : err
+ ? callback(err)
+ : callback(null, options.binary ? contents : contents.toString("utf8"));
+ });
+
+ // use the XHR version otherwise.
+ return fetch.xhr(filename, options, callback);
+}
+
+/**
+ * Fetches the contents of a file.
+ * @name util.fetch
+ * @function
+ * @param {string} path File path or url
+ * @param {FetchCallback} callback Callback function
+ * @returns {undefined}
+ * @variation 2
+ */
+
+/**
+ * Fetches the contents of a file.
+ * @name util.fetch
+ * @function
+ * @param {string} path File path or url
+ * @param {FetchOptions} [options] Fetch options
+ * @returns {Promise<string|Uint8Array>} Promise
+ * @variation 3
+ */
+
+/**/
+fetch.xhr = function fetch_xhr(filename, options, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() {
+
+ if (xhr.readyState !== 4)
+ return undefined;
+
+ // local cors security errors return status 0 / empty string, too. afaik this cannot be
+ // reliably distinguished from an actually empty file for security reasons. feel free
+ // to send a pull request if you are aware of a solution.
+ if (xhr.status !== 0 && xhr.status !== 200)
+ return callback(Error("status " + xhr.status));
+
+ // if binary data is expected, make sure that some sort of array is returned, even if
+ // ArrayBuffers are not supported. the binary string fallback, however, is unsafe.
+ if (options.binary) {
+ var buffer = xhr.response;
+ if (!buffer) {
+ buffer = [];
+ for (var i = 0; i < xhr.responseText.length; ++i)
+ buffer.push(xhr.responseText.charCodeAt(i) & 255);
+ }
+ return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer);
+ }
+ return callback(null, xhr.responseText);
+ };
+
+ if (options.binary) {
+ // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers
+ if ("overrideMimeType" in xhr)
+ xhr.overrideMimeType("text/plain; charset=x-user-defined");
+ xhr.responseType = "arraybuffer";
+ }
+
+ xhr.open("GET", filename);
+ xhr.send();
+};
diff --git a/frontend-old/node_modules/@protobufjs/fetch/package.json b/frontend-old/node_modules/@protobufjs/fetch/package.json new file mode 100644 index 0000000..10096ea --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/package.json @@ -0,0 +1,25 @@ +{
+ "name": "@protobufjs/fetch",
+ "description": "Fetches the contents of a file accross node and browsers.",
+ "version": "1.1.0",
+ "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/dcodeIO/protobuf.js.git"
+ },
+ "dependencies": {
+ "@protobufjs/aspromise": "^1.1.1",
+ "@protobufjs/inquire": "^1.1.0"
+ },
+ "license": "BSD-3-Clause",
+ "main": "index.js",
+ "types": "index.d.ts",
+ "devDependencies": {
+ "istanbul": "^0.4.5",
+ "tape": "^4.6.3"
+ },
+ "scripts": {
+ "test": "tape tests/*.js",
+ "coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
+ }
+}
\ No newline at end of file diff --git a/frontend-old/node_modules/@protobufjs/fetch/tests/index.js b/frontend-old/node_modules/@protobufjs/fetch/tests/index.js new file mode 100644 index 0000000..3cb0dae --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/fetch/tests/index.js @@ -0,0 +1,16 @@ +var tape = require("tape");
+
+var fetch = require("..");
+
+tape.test("fetch", function(test) {
+
+ if (typeof Promise !== "undefined") {
+ var promise = fetch("NOTFOUND");
+ promise.catch(function() {});
+ test.ok(promise instanceof Promise, "should return a promise if callback has been omitted");
+ }
+
+ // TODO - some way to test this properly?
+
+ test.end();
+});
|
