UNPKG

@junobuild/cli-tools

Version:

A collection of tools for Juno CLIs and Plugins.

4 lines 1.25 MB
{ "version": 3, "sources": ["../../../../node_modules/ieee754/index.js", "../../../../node_modules/strtok3/lib/stream/Errors.js", "../../../../node_modules/strtok3/lib/stream/Deferred.js", "../../../../node_modules/strtok3/lib/stream/AbstractStreamReader.js", "../../../../node_modules/strtok3/lib/stream/StreamReader.js", "../../../../node_modules/strtok3/lib/stream/WebStreamReader.js", "../../../../node_modules/strtok3/lib/stream/WebStreamByobReader.js", "../../../../node_modules/strtok3/lib/stream/WebStreamDefaultReader.js", "../../../../node_modules/strtok3/lib/stream/WebStreamReaderFactory.js", "../../../../node_modules/strtok3/lib/stream/index.js", "../../../../node_modules/strtok3/lib/AbstractTokenizer.js", "../../../../node_modules/strtok3/lib/ReadStreamTokenizer.js", "../../../../node_modules/strtok3/lib/BufferTokenizer.js", "../../../../node_modules/strtok3/lib/BlobTokenizer.js", "../../../../node_modules/strtok3/lib/core.js", "../../../../node_modules/ms/index.js", "../../../../node_modules/debug/src/common.js", "../../../../node_modules/debug/src/browser.js", "../../../../node_modules/has-flag/index.js", "../../../../node_modules/supports-color/index.js", "../../../../node_modules/debug/src/node.js", "../../../../node_modules/debug/src/index.js", "../../../../node_modules/strtok3/lib/FileTokenizer.js", "../../../../node_modules/strtok3/lib/index.js", "../../../../node_modules/mime-db/db.json", "../../../../node_modules/mime-db/index.js", "../../../../node_modules/mime-types/mimeScore.js", "../../../../node_modules/mime-types/index.js", "../../../../node_modules/eventemitter3/index.js", "../../../../node_modules/rfdc/index.js", "../../../../node_modules/environment/index.js", "../../../../node_modules/ansi-escapes/base.js", "../../../../node_modules/ansi-escapes/index.js", "../../../../node_modules/mimic-function/index.js", "../../../../node_modules/onetime/index.js", "../../../../node_modules/signal-exit/src/signals.ts", "../../../../node_modules/signal-exit/src/index.ts", "../../../../node_modules/restore-cursor/index.js", "../../../../node_modules/cli-cursor/index.js", "../../../../node_modules/ansi-regex/index.js", "../../../../node_modules/strip-ansi/index.js", "../../../../node_modules/get-east-asian-width/lookup-data.js", "../../../../node_modules/get-east-asian-width/utilities.js", "../../../../node_modules/get-east-asian-width/lookup.js", "../../../../node_modules/get-east-asian-width/index.js", "../../../../node_modules/emoji-regex/index.js", "../../../../node_modules/string-width/index.js", "../../../../node_modules/wrap-ansi/node_modules/ansi-styles/index.js", "../../../../node_modules/wrap-ansi/index.js", "../../../../node_modules/slice-ansi/node_modules/ansi-styles/index.js", "../../../../node_modules/is-fullwidth-code-point/index.js", "../../../../node_modules/slice-ansi/index.js", "../../../../node_modules/log-update/index.js", "../../../../node_modules/cli-truncate/node_modules/ansi-styles/index.js", "../../../../node_modules/cli-truncate/node_modules/slice-ansi/tokenize-ansi.js", "../../../../node_modules/cli-truncate/node_modules/slice-ansi/index.js", "../../../../node_modules/cli-truncate/node_modules/string-width/index.js", "../../../../node_modules/cli-truncate/index.js", "../../../../node_modules/listr2/node_modules/string-width/index.js", "../../../../node_modules/listr2/node_modules/ansi-styles/index.js", "../../../../node_modules/listr2/node_modules/wrap-ansi/index.js", "../../src/commands/build.ts", "../../src/commands/deploy.ts", "../../src/constants/deploy.constants.ts", "../../src/constants/storage.constants.ts", "../../src/utils/cmd.utils.ts", "../../src/utils/cmd.windows.utils.ts", "../../src/services/deploy.hook.services.ts", "../../src/services/deploy.prepare.services.ts", "../../../../node_modules/token-types/lib/index.js", "../../../../node_modules/@borewit/text-codec/lib/index.js", "../../../../node_modules/file-type/source/index.js", "../../../../node_modules/@tokenizer/inflate/lib/ZipHandler.js", "../../../../node_modules/@tokenizer/inflate/lib/ZipToken.js", "../../../../node_modules/@tokenizer/inflate/lib/GzipHandler.js", "../../../../node_modules/uint8array-extras/index.js", "../../../../node_modules/file-type/source/tokens.js", "../../../../node_modules/file-type/source/supported.js", "../../../../node_modules/file-type/source/parser.js", "../../../../node_modules/file-type/source/detectors/zip.js", "../../../../node_modules/file-type/source/detectors/ebml.js", "../../../../node_modules/file-type/source/detectors/png.js", "../../../../node_modules/file-type/source/detectors/asf.js", "../../../../node_modules/brace-expansion/node_modules/balanced-match/src/index.ts", "../../../../node_modules/brace-expansion/src/index.ts", "../../node_modules/minimatch/src/assert-valid-pattern.ts", "../../node_modules/minimatch/src/brace-expressions.ts", "../../node_modules/minimatch/src/unescape.ts", "../../node_modules/minimatch/src/ast.ts", "../../node_modules/minimatch/src/escape.ts", "../../node_modules/minimatch/src/index.ts", "../../src/utils/assets.utils.ts", "../../src/utils/compress.utils.ts", "../../src/utils/deploy.utils.ts", "../../src/utils/fs.utils.ts", "../../src/services/proposals.services.ts", "../../src/utils/format.utils.ts", "../../../../node_modules/eventemitter3/index.mjs", "../../../../node_modules/listr2/dist/index.mjs", "../../src/services/upload/upload.batch.services.ts", "../../src/services/upload/_upload.services.ts", "../../src/utils/upload.utils.ts", "../../src/services/upload/upload.individual.services.ts", "../../src/services/upload.services.ts", "../../src/services/deploy.proposal.services.ts", "../../src/commands/generate.ts", "../../src/commands/prune.ts", "../../src/services/prune.prepare.services.ts", "../../src/utils/prune.utils.ts", "../../src/services/prune.services.ts", "../../src/commands/publish.ts", "../../src/utils/args.utils.ts", "../../src/utils/download.utils.ts", "../../src/utils/pkg.utils.ts", "../../src/utils/prompt.utils.ts"], "sourcesContent": ["/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n", "export const defaultMessages = 'End-Of-Stream';\n/**\n * Thrown on read operation of the end of file or stream has been reached\n */\nexport class EndOfStreamError extends Error {\n constructor() {\n super(defaultMessages);\n this.name = \"EndOfStreamError\";\n }\n}\nexport class AbortError extends Error {\n constructor(message = \"The operation was aborted\") {\n super(message);\n this.name = \"AbortError\";\n }\n}\n", "export class Deferred {\n constructor() {\n this.resolve = () => null;\n this.reject = () => null;\n this.promise = new Promise((resolve, reject) => {\n this.reject = reject;\n this.resolve = resolve;\n });\n }\n}\n", "import { EndOfStreamError, AbortError } from \"./Errors.js\";\nexport class AbstractStreamReader {\n constructor() {\n this.endOfStream = false;\n this.interrupted = false;\n /**\n * Store peeked data\n * @type {Array}\n */\n this.peekQueue = [];\n }\n async peek(uint8Array, mayBeLess = false) {\n const bytesRead = await this.read(uint8Array, mayBeLess);\n this.peekQueue.push(uint8Array.subarray(0, bytesRead)); // Put read data back to peek buffer\n return bytesRead;\n }\n async read(buffer, mayBeLess = false) {\n if (buffer.length === 0) {\n return 0;\n }\n let bytesRead = this.readFromPeekBuffer(buffer);\n if (!this.endOfStream) {\n bytesRead += await this.readRemainderFromStream(buffer.subarray(bytesRead), mayBeLess);\n }\n if (bytesRead === 0 && !mayBeLess) {\n throw new EndOfStreamError();\n }\n return bytesRead;\n }\n /**\n * Read chunk from stream\n * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in\n * @returns Number of bytes read\n */\n readFromPeekBuffer(buffer) {\n let remaining = buffer.length;\n let bytesRead = 0;\n // consume peeked data first\n while (this.peekQueue.length > 0 && remaining > 0) {\n const peekData = this.peekQueue.pop(); // Front of queue\n if (!peekData)\n throw new Error('peekData should be defined');\n const lenCopy = Math.min(peekData.length, remaining);\n buffer.set(peekData.subarray(0, lenCopy), bytesRead);\n bytesRead += lenCopy;\n remaining -= lenCopy;\n if (lenCopy < peekData.length) {\n // remainder back to queue\n this.peekQueue.push(peekData.subarray(lenCopy));\n }\n }\n return bytesRead;\n }\n async readRemainderFromStream(buffer, mayBeLess) {\n let bytesRead = 0;\n // Continue reading from stream if required\n while (bytesRead < buffer.length && !this.endOfStream) {\n if (this.interrupted) {\n throw new AbortError();\n }\n const chunkLen = await this.readFromStream(buffer.subarray(bytesRead), mayBeLess);\n if (chunkLen === 0)\n break;\n bytesRead += chunkLen;\n }\n if (!mayBeLess && bytesRead < buffer.length) {\n throw new EndOfStreamError();\n }\n return bytesRead;\n }\n}\n", "import { AbortError, } from './Errors.js';\nimport { Deferred } from './Deferred.js';\nimport { AbstractStreamReader } from \"./AbstractStreamReader.js\";\n/**\n * Node.js Readable Stream Reader\n * Ref: https://nodejs.org/api/stream.html#readable-streams\n */\nexport class StreamReader extends AbstractStreamReader {\n constructor(s) {\n super();\n this.s = s;\n /**\n * Deferred used for postponed read request (as not data is yet available to read)\n */\n this.deferred = null;\n if (!s.read || !s.once) {\n throw new Error('Expected an instance of stream.Readable');\n }\n this.s.once('end', () => {\n this.endOfStream = true;\n if (this.deferred) {\n this.deferred.resolve(0);\n }\n });\n this.s.once('error', err => this.reject(err));\n this.s.once('close', () => this.abort());\n }\n /**\n * Read chunk from stream\n * @param buffer Target Uint8Array (or Buffer) to store data read from stream in\n * @param mayBeLess - If true, may fill the buffer partially\n * @returns Number of bytes read\n */\n async readFromStream(buffer, mayBeLess) {\n if (buffer.length === 0)\n return 0;\n const readBuffer = this.s.read(buffer.length);\n if (readBuffer) {\n buffer.set(readBuffer);\n return readBuffer.length;\n }\n const request = {\n buffer,\n mayBeLess,\n deferred: new Deferred()\n };\n this.deferred = request.deferred;\n this.s.once('readable', () => {\n this.readDeferred(request);\n });\n return request.deferred.promise;\n }\n /**\n * Process deferred read request\n * @param request Deferred read request\n */\n readDeferred(request) {\n const readBuffer = this.s.read(request.buffer.length);\n if (readBuffer) {\n request.buffer.set(readBuffer);\n request.deferred.resolve(readBuffer.length);\n this.deferred = null;\n }\n else {\n this.s.once('readable', () => {\n this.readDeferred(request);\n });\n }\n }\n reject(err) {\n this.interrupted = true;\n if (this.deferred) {\n this.deferred.reject(err);\n this.deferred = null;\n }\n }\n async abort() {\n this.reject(new AbortError());\n }\n async close() {\n return this.abort();\n }\n}\n", "import { AbstractStreamReader } from \"./AbstractStreamReader.js\";\nexport class WebStreamReader extends AbstractStreamReader {\n constructor(reader) {\n super();\n this.reader = reader;\n }\n async abort() {\n return this.close();\n }\n async close() {\n this.reader.releaseLock();\n }\n}\n", "import { WebStreamReader } from './WebStreamReader.js';\n/**\n * Read from a WebStream using a BYOB reader\n * Reference: https://nodejs.org/api/webstreams.html#class-readablestreambyobreader\n */\nexport class WebStreamByobReader extends WebStreamReader {\n /**\n * Read from stream\n * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in\n * @param mayBeLess - If true, may fill the buffer partially\n * @protected Bytes read\n */\n async readFromStream(buffer, mayBeLess) {\n if (buffer.length === 0)\n return 0;\n // @ts-expect-error\n const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? undefined : buffer.length });\n if (result.done) {\n this.endOfStream = result.done;\n }\n if (result.value) {\n buffer.set(result.value);\n return result.value.length;\n }\n return 0;\n }\n}\n", "import { EndOfStreamError } from './Errors.js';\nimport { AbstractStreamReader } from \"./AbstractStreamReader.js\";\nexport class WebStreamDefaultReader extends AbstractStreamReader {\n constructor(reader) {\n super();\n this.reader = reader;\n this.buffer = null; // Internal buffer to store excess data\n }\n /**\n * Copy chunk to target, and store the remainder in this.buffer\n */\n writeChunk(target, chunk) {\n const written = Math.min(chunk.length, target.length);\n target.set(chunk.subarray(0, written));\n // Adjust the remainder of the buffer\n if (written < chunk.length) {\n this.buffer = chunk.subarray(written);\n }\n else {\n this.buffer = null;\n }\n return written;\n }\n /**\n * Read from stream\n * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in\n * @param mayBeLess - If true, may fill the buffer partially\n * @protected Bytes read\n */\n async readFromStream(buffer, mayBeLess) {\n if (buffer.length === 0)\n return 0;\n let totalBytesRead = 0;\n // Serve from the internal buffer first\n if (this.buffer) {\n totalBytesRead += this.writeChunk(buffer, this.buffer);\n }\n // Continue reading from the stream if more data is needed\n while (totalBytesRead < buffer.length && !this.endOfStream) {\n const result = await this.reader.read();\n if (result.done) {\n this.endOfStream = true;\n break;\n }\n if (result.value) {\n totalBytesRead += this.writeChunk(buffer.subarray(totalBytesRead), result.value);\n }\n }\n if (!mayBeLess && totalBytesRead === 0 && this.endOfStream) {\n throw new EndOfStreamError();\n }\n return totalBytesRead;\n }\n abort() {\n this.interrupted = true;\n return this.reader.cancel();\n }\n async close() {\n await this.abort();\n this.reader.releaseLock();\n }\n}\n", "import { WebStreamByobReader } from './WebStreamByobReader.js';\nimport { WebStreamDefaultReader } from './WebStreamDefaultReader.js';\nexport function makeWebStreamReader(stream) {\n try {\n const reader = stream.getReader({ mode: \"byob\" });\n if (reader instanceof ReadableStreamDefaultReader) {\n // Fallback to default reader in case `mode: byob` is ignored\n return new WebStreamDefaultReader(reader);\n }\n return new WebStreamByobReader(reader);\n }\n catch (error) {\n if (error instanceof TypeError) {\n // Fallback to default reader in case `mode: byob` rejected by a `TypeError`\n return new WebStreamDefaultReader(stream.getReader());\n }\n throw error;\n }\n}\n", "export { AbortError, EndOfStreamError } from './Errors.js';\nexport { StreamReader } from './StreamReader.js';\nexport { WebStreamByobReader } from './WebStreamByobReader.js';\nexport { WebStreamDefaultReader } from './WebStreamDefaultReader.js';\nexport { makeWebStreamReader } from './WebStreamReaderFactory.js';\n", "import { EndOfStreamError } from './stream/index.js';\n/**\n * Core tokenizer\n */\nexport class AbstractTokenizer {\n /**\n * Constructor\n * @param options Tokenizer options\n * @protected\n */\n constructor(options) {\n this.numBuffer = new Uint8Array(8);\n /**\n * Tokenizer-stream position\n */\n this.position = 0;\n this.onClose = options?.onClose;\n if (options?.abortSignal) {\n options.abortSignal.addEventListener('abort', () => {\n this.abort();\n });\n }\n }\n /**\n * Read a token from the tokenizer-stream\n * @param token - The token to read\n * @param position - If provided, the desired position in the tokenizer-stream\n * @returns Promise with token data\n */\n async readToken(token, position = this.position) {\n const uint8Array = new Uint8Array(token.len);\n const len = await this.readBuffer(uint8Array, { position });\n if (len < token.len)\n throw new EndOfStreamError();\n return token.get(uint8Array, 0);\n }\n /**\n * Peek a token from the tokenizer-stream.\n * @param token - Token to peek from the tokenizer-stream.\n * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.\n * @returns Promise with token data\n */\n async peekToken(token, position = this.position) {\n const uint8Array = new Uint8Array(token.len);\n const len = await this.peekBuffer(uint8Array, { position });\n if (len < token.len)\n throw new EndOfStreamError();\n return token.get(uint8Array, 0);\n }\n /**\n * Read a numeric token from the stream\n * @param token - Numeric token\n * @returns Promise with number\n */\n async readNumber(token) {\n const len = await this.readBuffer(this.numBuffer, { length: token.len });\n if (len < token.len)\n throw new EndOfStreamError();\n return token.get(this.numBuffer, 0);\n }\n /**\n * Read a numeric token from the stream\n * @param token - Numeric token\n * @returns Promise with number\n */\n async peekNumber(token) {\n const len = await this.peekBuffer(this.numBuffer, { length: token.len });\n if (len < token.len)\n throw new EndOfStreamError();\n return token.get(this.numBuffer, 0);\n }\n /**\n * Ignore number of bytes, advances the pointer in under tokenizer-stream.\n * @param length - Number of bytes to ignore. Must be \u2265 0.\n * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available\n */\n async ignore(length) {\n if (length < 0) {\n throw new RangeError('ignore length must be \u2265 0 bytes');\n }\n if (this.fileInfo.size !== undefined) {\n const bytesLeft = this.fileInfo.size - this.position;\n if (length > bytesLeft) {\n this.position += bytesLeft;\n return bytesLeft;\n }\n }\n this.position += length;\n return length;\n }\n async close() {\n await this.abort();\n await this.onClose?.();\n }\n normalizeOptions(uint8Array, options) {\n if (!this.supportsRandomAccess() && options && options.position !== undefined && options.position < this.position) {\n throw new Error('`options.position` must be equal or greater than `tokenizer.position`');\n }\n return {\n ...{\n mayBeLess: false,\n offset: 0,\n length: uint8Array.length,\n position: this.position\n }, ...options\n };\n }\n abort() {\n return Promise.resolve(); // Ignore abort signal\n }\n}\n", "import { AbstractTokenizer } from './AbstractTokenizer.js';\nimport { EndOfStreamError } from './stream/index.js';\nconst maxBufferSize = 256000;\nexport class ReadStreamTokenizer extends AbstractTokenizer {\n /**\n * Constructor\n * @param streamReader stream-reader to read from\n * @param options Tokenizer options\n */\n constructor(streamReader, options) {\n super(options);\n this.streamReader = streamReader;\n this.fileInfo = options?.fileInfo ?? {};\n }\n /**\n * Read buffer from tokenizer\n * @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream\n * @param options - Read behaviour options\n * @returns Promise with number of bytes read\n */\n async readBuffer(uint8Array, options) {\n const normOptions = this.normalizeOptions(uint8Array, options);\n const skipBytes = normOptions.position - this.position;\n if (skipBytes > 0) {\n await this.ignore(skipBytes);\n return this.readBuffer(uint8Array, options);\n }\n if (skipBytes < 0) {\n throw new Error('`options.position` must be equal or greater than `tokenizer.position`');\n }\n if (normOptions.length === 0) {\n return 0;\n }\n const bytesRead = await this.streamReader.read(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);\n this.position += bytesRead;\n if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) {\n throw new EndOfStreamError();\n }\n return bytesRead;\n }\n /**\n * Peek (read ahead) buffer from tokenizer\n * @param uint8Array - Uint8Array (or Buffer) to write data to\n * @param options - Read behaviour options\n * @returns Promise with number of bytes peeked\n */\n async peekBuffer(uint8Array, options) {\n const normOptions = this.normalizeOptions(uint8Array, options);\n let bytesRead = 0;\n if (normOptions.position) {\n const skipBytes = normOptions.position - this.position;\n if (skipBytes > 0) {\n const skipBuffer = new Uint8Array(normOptions.length + skipBytes);\n bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: normOptions.mayBeLess });\n uint8Array.set(skipBuffer.subarray(skipBytes));\n return bytesRead - skipBytes;\n }\n if (skipBytes < 0) {\n throw new Error('Cannot peek from a negative offset in a stream');\n }\n }\n if (normOptions.length > 0) {\n try {\n bytesRead = await this.streamReader.peek(uint8Array.subarray(0, normOptions.length), normOptions.mayBeLess);\n }\n catch (err) {\n if (options?.mayBeLess && err instanceof EndOfStreamError) {\n return 0;\n }\n throw err;\n }\n if ((!normOptions.mayBeLess) && bytesRead < normOptions.length) {\n throw new EndOfStreamError();\n }\n }\n return bytesRead;\n }\n /**\n * @param length Number of bytes to ignore. Must be \u2265 0.\n */\n async ignore(length) {\n if (length < 0) {\n throw new RangeError('ignore length must be \u2265 0 bytes');\n }\n const bufSize = Math.min(maxBufferSize, length);\n const buf = new Uint8Array(bufSize);\n let totBytesRead = 0;\n while (totBytesRead < length) {\n const remaining = length - totBytesRead;\n const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) });\n if (bytesRead < 0) {\n return bytesRead;\n }\n totBytesRead += bytesRead;\n }\n return totBytesRead;\n }\n abort() {\n return this.streamReader.abort();\n }\n async close() {\n return this.streamReader.close();\n }\n supportsRandomAccess() {\n return false;\n }\n}\n", "import { EndOfStreamError } from './stream/index.js';\nimport { AbstractTokenizer } from './AbstractTokenizer.js';\nexport class BufferTokenizer extends AbstractTokenizer {\n /**\n * Construct BufferTokenizer\n * @param uint8Array - Uint8Array to tokenize\n * @param options Tokenizer options\n */\n constructor(uint8Array, options) {\n super(options);\n this.uint8Array = uint8Array;\n this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: uint8Array.length } };\n }\n /**\n * Read buffer from tokenizer\n * @param uint8Array - Uint8Array to tokenize\n * @param options - Read behaviour options\n * @returns {Promise<number>}\n */\n async readBuffer(uint8Array, options) {\n if (options?.position) {\n this.position = options.position;\n }\n const bytesRead = await this.peekBuffer(uint8Array, options);\n this.position += bytesRead;\n return bytesRead;\n }\n /**\n * Peek (read ahead) buffer from tokenizer\n * @param uint8Array\n * @param options - Read behaviour options\n * @returns {Promise<number>}\n */\n async peekBuffer(uint8Array, options) {\n const normOptions = this.normalizeOptions(uint8Array, options);\n const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length);\n if ((!normOptions.mayBeLess) && bytes2read < normOptions.length) {\n throw new EndOfStreamError();\n }\n uint8Array.set(this.uint8Array.subarray(normOptions.position, normOptions.position + bytes2read));\n return bytes2read;\n }\n close() {\n return super.close();\n }\n supportsRandomAccess() {\n return true;\n }\n setPosition(position) {\n this.position = position;\n }\n}\n", "import { EndOfStreamError } from './stream/index.js';\nimport { AbstractTokenizer } from './AbstractTokenizer.js';\nexport class BlobTokenizer extends AbstractTokenizer {\n /**\n * Construct BufferTokenizer\n * @param blob - Uint8Array to tokenize\n * @param options Tokenizer options\n */\n constructor(blob, options) {\n super(options);\n this.blob = blob;\n this.fileInfo = { ...options?.fileInfo ?? {}, ...{ size: blob.size, mimeType: blob.type } };\n }\n /**\n * Read buffer from tokenizer\n * @param uint8Array - Uint8Array to tokenize\n * @param options - Read behaviour options\n * @returns {Promise<number>}\n */\n async readBuffer(uint8Array, options) {\n if (options?.position) {\n this.position = options.position;\n }\n const bytesRead = await this.peekBuffer(uint8Array, options);\n this.position += bytesRead;\n return bytesRead;\n }\n /**\n * Peek (read ahead) buffer from tokenizer\n * @param buffer\n * @param options - Read behaviour options\n * @returns {Promise<number>}\n */\n async peekBuffer(buffer, options) {\n const normOptions = this.normalizeOptions(buffer, options);\n const bytes2read = Math.min(this.blob.size - normOptions.position, normOptions.length);\n if ((!normOptions.mayBeLess) && bytes2read < normOptions.length) {\n throw new EndOfStreamError();\n }\n const arrayBuffer = await this.blob.slice(normOptions.position, normOptions.position + bytes2read).arrayBuffer();\n buffer.set(new Uint8Array(arrayBuffer));\n return bytes2read;\n }\n close() {\n return super.close();\n }\n supportsRandomAccess() {\n return true;\n }\n setPosition(position) {\n this.position = position;\n }\n}\n", "import { StreamReader, makeWebStreamReader } from './stream/index.js';\nimport { ReadStreamTokenizer } from './ReadStreamTokenizer.js';\nimport { BufferTokenizer } from './BufferTokenizer.js';\nimport { BlobTokenizer } from './BlobTokenizer.js';\nexport { EndOfStreamError, AbortError } from './stream/index.js';\nexport { AbstractTokenizer } from './AbstractTokenizer.js';\n/**\n * Construct ReadStreamTokenizer from given Stream.\n * Will set fileSize, if provided given Stream has set the .path property/\n * @param stream - Read from Node.js Stream.Readable\n * @param options - Tokenizer options\n * @returns ReadStreamTokenizer\n */\nexport function fromStream(stream, options) {\n const streamReader = new StreamReader(stream);\n const _options = options ?? {};\n const chainedClose = _options.onClose;\n _options.onClose = async () => {\n await streamReader.close();\n if (chainedClose) {\n return chainedClose();\n }\n };\n return new ReadStreamTokenizer(streamReader, _options);\n}\n/**\n * Construct ReadStreamTokenizer from given ReadableStream (WebStream API).\n * Will set fileSize, if provided given Stream has set the .path property/\n * @param webStream - Read from Node.js Stream.Readable (must be a byte stream)\n * @param options - Tokenizer options\n * @returns ReadStreamTokenizer\n */\nexport function fromWebStream(webStream, options) {\n const webStreamReader = makeWebStreamReader(webStream);\n const _options = options ?? {};\n const chainedClose = _options.onClose;\n _options.onClose = async () => {\n await webStreamReader.close();\n if (chainedClose) {\n return chainedClose();\n }\n };\n return new ReadStreamTokenizer(webStreamReader, _options);\n}\n/**\n * Construct ReadStreamTokenizer from given Buffer.\n * @param uint8Array - Uint8Array to tokenize\n * @param options - Tokenizer options\n * @returns BufferTokenizer\n */\nexport function fromBuffer(uint8Array, options) {\n return new BufferTokenizer(uint8Array, options);\n}\n/**\n * Construct ReadStreamTokenizer from given Blob.\n * @param blob - Uint8Array to tokenize\n * @param options - Tokenizer options\n * @returns BufferTokenizer\n */\nexport function fromBlob(blob, options) {\n return new BlobTokenizer(blob, options);\n}\n", "/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function (val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n", "\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '')\n\t\t\t.trim()\n\t\t\t.replace(/\\s+/g, ',')\n\t\t\t.split(',')\n\t\t\t.filter(Boolean);\n\n\t\tfor (const ns of split) {\n\t\t\tif (ns[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(ns.slice(1));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(ns);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the given string matches a namespace template, honoring\n\t * asterisks as wildcards.\n\t *\n\t * @param {String} search\n\t * @param {String} template\n\t * @return {Boolean}\n\t */\n\tfunction matchesTemplate(search, template) {\n\t\tlet searchIndex = 0;\n\t\tlet templateIndex = 0;\n\t\tlet starIndex = -1;\n\t\tlet matchIndex = 0;\n\n\t\twhile (searchIndex < search.length) {\n\t\t\tif (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {\n\t\t\t\t// Match character or proceed with wildcard\n\t\t\t\tif (template[templateIndex] === '*') {\n\t\t\t\t\tstarIndex = templateIndex;\n\t\t\t\t\tmatchIndex = searchIndex;\n\t\t\t\t\ttemplateIndex++; // Skip the '*'\n\t\t\t\t} else {\n\t\t\t\t\tsearchIndex++;\n\t\t\t\t\ttemplateIndex++;\n\t\t\t\t}\n\t\t\t} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition\n\t\t\t\t// Backtrack to the last '*' and try to match more characters\n\t\t\t\ttemplateIndex = starIndex + 1;\n\t\t\t\tmatchIndex++;\n\t\t\t\tsearchIndex = matchIndex;\n\t\t\t} else {\n\t\t\t\treturn false; // No match\n\t\t\t}\n\t\t}\n\n\t\t// Handle trailing '*' in template\n\t\twhile (templateIndex < template.length && template[templateIndex] === '*') {\n\t\t\ttemplateIndex++;\n\t\t}\n\n\t\treturn templateIndex === template.length;\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names,\n\t\t\t...createDebug.skips.map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tfor (const skip of createDebug.skips) {\n\t\t\tif (matchesTemplate(name, skip)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (const ns of createDebug.names) {\n\t\t\tif (matchesTemplate(name, ns)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n", "/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\tlet m;\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\t// eslint-disable-next-line no-return-assign\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)) && parseInt(m[1], 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t