@volter/tabnode 0.5.17 → 0.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{runtime-worker-DCIwIWHJ.js → runtime-worker-C-l9pCp3.js} +622 -126
- package/dist/index.mjs +568 -91
- package/dist/node-lib/internals/amaro.d.ts +31 -0
- package/dist/node-lib/internals/runtime.d.ts +1 -0
- package/dist/node-lib/node-versions.d.ts +1 -0
- package/dist/node-lib/typescript-module.d.ts +11 -0
- package/dist/process-tokens.d.ts +2 -0
- package/dist/shims/process.d.ts +3 -0
- package/dist/shims/shell-jobs.d.ts +12 -0
- package/dist/shims/streamed-output.d.ts +14 -0
- package/package.json +2 -1
- package/src/node-lib/internal/modules/typescript.js +183 -0
- package/src/node-lib/internals/amaro.ts +51 -0
- package/src/node-lib/internals/index.ts +2 -0
- package/src/node-lib/internals/runtime.ts +16 -1
- package/src/node-lib/node-versions.ts +4 -1
- package/src/node-lib/sources.ts +2 -0
- package/src/node-lib/typescript-module.ts +50 -0
- package/src/process-tokens.ts +6 -0
- package/src/runtime.ts +38 -15
- package/src/shims/child_process.ts +15 -7
- package/src/shims/process.ts +2 -2
- package/src/shims/shell-jobs.ts +451 -0
- package/src/shims/streamed-output.ts +25 -0
package/dist/index.mjs
CHANGED
|
@@ -563,6 +563,7 @@ const INTERNAL_VALIDATORS = "/* eslint jsdoc/require-jsdoc: \"error\" */\n\n'use
|
|
|
563
563
|
const INTERNAL_ABORT_LISTENER = "'use strict';\n\nconst {\n SymbolDispose,\n} = require('internal/util');\nconst {\n validateAbortSignal,\n validateFunction,\n} = require('internal/validators');\nconst {\n codes: {\n ERR_INVALID_ARG_TYPE,\n },\n} = require('internal/errors');\n\nlet queueMicrotask;\nlet kResistStopPropagation;\n\n/**\n * @param {AbortSignal} signal\n * @param {EventListener} listener\n * @returns {Disposable}\n */\nfunction addAbortListener(signal, listener) {\n if (signal === undefined) {\n throw new ERR_INVALID_ARG_TYPE('signal', 'AbortSignal', signal);\n }\n validateAbortSignal(signal, 'signal');\n validateFunction(listener, 'listener');\n\n let removeEventListener;\n if (signal.aborted) {\n queueMicrotask ??= require('internal/process/task_queues').queueMicrotask;\n queueMicrotask(() => listener());\n } else {\n kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;\n // TODO(atlowChemi) add { subscription: true } and return directly\n signal.addEventListener('abort', listener, { __proto__: null, once: true, [kResistStopPropagation]: true });\n removeEventListener = () => {\n signal.removeEventListener('abort', listener);\n };\n }\n return {\n __proto__: null,\n [SymbolDispose]() {\n removeEventListener?.();\n },\n };\n}\n\nmodule.exports = {\n __proto__: null,\n addAbortListener,\n};\n";
|
|
564
564
|
const INTERNAL_CHILD_PROCESS_SERIALIZATION = "'use strict';\n\nconst {\n ArrayPrototypePush,\n JSONParse,\n JSONStringify,\n StringPrototypeSplit,\n Symbol,\n TypedArrayPrototypeSubarray,\n} = primordials;\nconst { Buffer } = require('buffer');\nconst { StringDecoder } = require('string_decoder');\nconst v8 = require('v8');\nconst { isArrayBufferView } = require('internal/util/types');\nconst assert = require('internal/assert');\nconst { streamBaseState, kLastWriteWasAsync } = internalBinding('stream_wrap');\n\nconst kMessageBuffer = Symbol('kMessageBuffer');\nconst kMessageBufferSize = Symbol('kMessageBufferSize');\nconst kJSONBuffer = Symbol('kJSONBuffer');\nconst kStringDecoder = Symbol('kStringDecoder');\n\n// Extend V8's serializer APIs to give more JSON-like behaviour in\n// some cases; in particular, for native objects this serializes them the same\n// way that JSON does rather than throwing an exception.\nconst kArrayBufferViewTag = 0;\nconst kNotArrayBufferViewTag = 1;\nclass ChildProcessSerializer extends v8.DefaultSerializer {\n _writeHostObject(object) {\n if (isArrayBufferView(object)) {\n this.writeUint32(kArrayBufferViewTag);\n return super._writeHostObject(object);\n }\n this.writeUint32(kNotArrayBufferViewTag);\n this.writeValue({ ...object });\n }\n}\n\nclass ChildProcessDeserializer extends v8.DefaultDeserializer {\n _readHostObject() {\n const tag = this.readUint32();\n if (tag === kArrayBufferViewTag)\n return super._readHostObject();\n\n assert(tag === kNotArrayBufferViewTag);\n return this.readValue();\n }\n}\n\n// Messages are parsed in either of the following formats:\n// - Newline-delimited JSON, or\n// - V8-serialized buffers, prefixed with their length as a big endian uint32\n// (aka 'advanced')\nconst advanced = {\n initMessageChannel(channel) {\n channel[kMessageBuffer] = [];\n channel[kMessageBufferSize] = 0;\n channel.buffering = false;\n },\n\n *parseChannelMessages(channel, readData) {\n if (readData.length === 0) return;\n\n if (channel[kMessageBufferSize] && channel[kMessageBuffer][0].length < 4) {\n // Message length split into two buffers, so let's concatenate it.\n channel[kMessageBuffer][0] = Buffer.concat([channel[kMessageBuffer][0], readData]);\n } else {\n ArrayPrototypePush(channel[kMessageBuffer], readData);\n }\n channel[kMessageBufferSize] += readData.length;\n\n // Index 0 should always be present because we just pushed data into it.\n let messageBufferHead = channel[kMessageBuffer][0];\n while (messageBufferHead.length >= 4) {\n // We call `readUInt32BE` manually here, because this is faster than first converting\n // it to a buffer and using `readUInt32BE` on that.\n const fullMessageSize = (\n messageBufferHead[0] << 24 |\n messageBufferHead[1] << 16 |\n messageBufferHead[2] << 8 |\n messageBufferHead[3]\n ) + 4;\n\n if (channel[kMessageBufferSize] < fullMessageSize) break;\n\n const concatenatedBuffer = channel[kMessageBuffer].length === 1 ?\n channel[kMessageBuffer][0] :\n Buffer.concat(\n channel[kMessageBuffer],\n channel[kMessageBufferSize],\n );\n\n const deserializer = new ChildProcessDeserializer(\n TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize),\n );\n\n messageBufferHead = TypedArrayPrototypeSubarray(concatenatedBuffer, fullMessageSize);\n channel[kMessageBufferSize] = messageBufferHead.length;\n channel[kMessageBuffer] =\n channel[kMessageBufferSize] !== 0 ? [messageBufferHead] : [];\n\n deserializer.readHeader();\n yield deserializer.readValue();\n }\n\n channel.buffering = channel[kMessageBufferSize] > 0;\n },\n\n writeChannelMessage(channel, req, message, handle) {\n const ser = new ChildProcessSerializer();\n // Add 4 bytes, to later populate with message length\n ser.writeRawBytes(Buffer.allocUnsafe(4));\n ser.writeHeader();\n ser.writeValue(message);\n\n const serializedMessage = ser.releaseBuffer();\n const serializedMessageLength = serializedMessage.length - 4;\n\n serializedMessage.set([\n serializedMessageLength >> 24 & 0xFF,\n serializedMessageLength >> 16 & 0xFF,\n serializedMessageLength >> 8 & 0xFF,\n serializedMessageLength & 0xFF,\n ], 0);\n\n const result = channel.writeBuffer(req, serializedMessage, handle);\n\n // Mirror what stream_base_commons.js does for Buffer retention.\n if (streamBaseState[kLastWriteWasAsync])\n req.buffer = serializedMessage;\n\n return result;\n },\n};\n\nconst json = {\n initMessageChannel(channel) {\n channel[kJSONBuffer] = '';\n channel[kStringDecoder] = undefined;\n },\n\n *parseChannelMessages(channel, readData) {\n if (readData.length === 0) return;\n\n if (channel[kStringDecoder] === undefined)\n channel[kStringDecoder] = new StringDecoder('utf8');\n const chunks =\n StringPrototypeSplit(channel[kStringDecoder].write(readData), '\\n');\n const numCompleteChunks = chunks.length - 1;\n // Last line does not have trailing linebreak\n const incompleteChunk = chunks[numCompleteChunks];\n if (numCompleteChunks === 0) {\n channel[kJSONBuffer] += incompleteChunk;\n } else {\n chunks[0] = channel[kJSONBuffer] + chunks[0];\n for (let i = 0; i < numCompleteChunks; i++)\n yield JSONParse(chunks[i]);\n channel[kJSONBuffer] = incompleteChunk;\n }\n channel.buffering = channel[kJSONBuffer].length !== 0;\n },\n\n writeChannelMessage(channel, req, message, handle) {\n const string = JSONStringify(message) + '\\n';\n return channel.writeUtf8String(req, string, handle);\n },\n};\n\nmodule.exports = { advanced, json };\n";
|
|
565
565
|
const INTERNAL_MODULES_CUSTOMIZATION_HOOKS = "'use strict';\n\nconst {\n ArrayPrototypeFindIndex,\n ArrayPrototypePush,\n ArrayPrototypeSplice,\n ObjectAssign,\n ObjectFreeze,\n StringPrototypeSlice,\n StringPrototypeStartsWith,\n Symbol,\n} = primordials;\nconst {\n isAnyArrayBuffer,\n isArrayBufferView,\n} = require('internal/util/types');\n\nconst { BuiltinModule } = require('internal/bootstrap/realm');\nconst {\n ERR_INVALID_RETURN_PROPERTY_VALUE,\n} = require('internal/errors').codes;\nconst { validateFunction } = require('internal/validators');\nconst { isAbsolute } = require('path');\nconst { pathToFileURL, fileURLToPath } = require('internal/url');\n\nlet debug = require('internal/util/debuglog').debuglog('module_hooks', (fn) => {\n debug = fn;\n});\n\n/**\n * @typedef {import('internal/modules/cjs/loader.js').Module} Module\n */\n/**\n * @typedef {(\n * specifier: string,\n * context: Partial<ModuleResolveContext>,\n * ) => ModuleResolveResult\n * } NextResolve\n * @typedef {(\n * specifier: string,\n * context: ModuleResolveContext,\n * nextResolve: NextResolve,\n * ) => ModuleResolveResult\n * } ResolveHook\n * @typedef {(\n * url: string,\n * context: Partial<ModuleLoadContext>,\n * ) => ModuleLoadResult\n * } NextLoad\n * @typedef {(\n * url: string,\n * context: ModuleLoadContext,\n * nextLoad: NextLoad,\n * ) => ModuleLoadResult\n * } LoadHook\n */\n\n// Use arrays for better insertion and iteration performance, we don't care\n// about deletion performance as much.\n\n/** @type {ResolveHook[]} */\nconst resolveHooks = [];\n/** @type {LoadHook[]} */\nconst loadHooks = [];\nconst hookId = Symbol('kModuleHooksIdKey');\nlet nextHookId = 0;\n\nclass ModuleHooks {\n /**\n * @param {ResolveHook|undefined} resolve User-provided hook.\n * @param {LoadHook|undefined} load User-provided hook.\n */\n constructor(resolve, load) {\n this[hookId] = Symbol(`module-hook-${nextHookId++}`);\n // Always initialize all hooks, if it's unspecified it'll be an owned undefined.\n this.resolve = resolve;\n this.load = load;\n\n if (resolve) {\n ArrayPrototypePush(resolveHooks, this);\n }\n if (load) {\n ArrayPrototypePush(loadHooks, this);\n }\n\n ObjectFreeze(this);\n }\n // TODO(joyeecheung): we may want methods that allow disabling/enabling temporarily\n // which just sets the item in the array to undefined temporarily.\n // TODO(joyeecheung): this can be the [Symbol.dispose] implementation to pair with\n // `using` when the explicit resource management proposal is shipped by V8.\n /**\n * Deregister the hook instance.\n */\n deregister() {\n const id = this[hookId];\n let index = ArrayPrototypeFindIndex(resolveHooks, (hook) => hook[hookId] === id);\n if (index !== -1) {\n ArrayPrototypeSplice(resolveHooks, index, 1);\n }\n index = ArrayPrototypeFindIndex(loadHooks, (hook) => hook[hookId] === id);\n if (index !== -1) {\n ArrayPrototypeSplice(loadHooks, index, 1);\n }\n }\n};\n\n/**\n * TODO(joyeecheung): taken an optional description?\n * @param {{ resolve?: ResolveHook, load?: LoadHook }} hooks User-provided hooks\n * @returns {ModuleHooks}\n */\nfunction registerHooks(hooks) {\n const { resolve, load } = hooks;\n if (resolve) {\n validateFunction(resolve, 'hooks.resolve');\n }\n if (load) {\n validateFunction(load, 'hooks.load');\n }\n return new ModuleHooks(resolve, load);\n}\n\n/**\n * @param {string} filename\n * @returns {string}\n */\nfunction convertCJSFilenameToURL(filename) {\n if (!filename) { return filename; }\n let normalizedId = filename;\n if (StringPrototypeStartsWith(filename, 'node:')) {\n normalizedId = StringPrototypeSlice(filename, 5);\n }\n if (BuiltinModule.canBeRequiredByUsers(normalizedId)) {\n return `node:${normalizedId}`;\n }\n // Handle the case where filename is neither a path, nor a built-in id,\n // which is possible via monkey-patching.\n if (isAbsolute(filename)) {\n return pathToFileURL(filename).href;\n }\n return filename;\n}\n\n/**\n * @param {string} url\n * @returns {string}\n */\nfunction convertURLToCJSFilename(url) {\n if (!url) { return url; }\n const builtinId = BuiltinModule.normalizeRequirableId(url);\n if (builtinId) {\n return builtinId;\n }\n if (StringPrototypeStartsWith(url, 'file://')) {\n return fileURLToPath(url);\n }\n return url;\n}\n\n/**\n * Convert a list of hooks into a function that can be used to do an operation through\n * a chain of hooks. If any of the hook returns without calling the next hook, it\n * must return shortCircuit: true to stop the chain from continuing to avoid\n * forgetting to invoke the next hook by mistake.\n * @param {ModuleHooks[]} hooks A list of hooks whose last argument is `nextHook`.\n * @param {'load'|'resolve'} name Name of the hook in ModuleHooks.\n * @param {Function} defaultStep The default step in the chain.\n * @param {Function} validate A function that validates and sanitize the result returned by the chain.\n */\nfunction buildHooks(hooks, name, defaultStep, validate, mergedContext) {\n let lastRunIndex = hooks.length;\n /**\n * Helper function to wrap around invocation of user hook or the default step\n * in order to fill in missing arguments or check returned results.\n * Due to the merging of the context, this must be a closure.\n * @param {number} index Index in the chain. Default step is 0, last added hook is 1,\n * and so on.\n * @param {Function} userHookOrDefault Either the user hook or the default step to invoke.\n * @param {Function|undefined} next The next wrapped step. If this is the default step, it's undefined.\n * @returns {Function} Wrapped hook or default step.\n */\n function wrapHook(index, userHookOrDefault, next) {\n return function nextStep(arg0, context) {\n lastRunIndex = index;\n if (context && context !== mergedContext) {\n ObjectAssign(mergedContext, context);\n }\n const hookResult = userHookOrDefault(arg0, mergedContext, next);\n if (lastRunIndex > 0 && lastRunIndex === index && !hookResult.shortCircuit) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE('true', name, 'shortCircuit',\n hookResult.shortCircuit);\n }\n return validate(arg0, mergedContext, hookResult);\n };\n }\n const chain = [wrapHook(0, defaultStep)];\n for (let i = 0; i < hooks.length; ++i) {\n const wrappedHook = wrapHook(i + 1, hooks[i][name], chain[i]);\n ArrayPrototypePush(chain, wrappedHook);\n }\n return chain[chain.length - 1];\n}\n\n/**\n * @typedef {object} ModuleResolveResult\n * @property {string} url Resolved URL of the module.\n * @property {string|undefined} format Format of the module.\n * @property {ImportAttributes|undefined} importAttributes Import attributes for the request.\n * @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.\n */\n\n/**\n * Validate the result returned by a chain of resolve hook.\n * @param {string} specifier Specifier passed into the hooks.\n * @param {ModuleResolveContext} context Context passed into the hooks.\n * @param {ModuleResolveResult} result Result produced by resolve hooks.\n * @returns {ModuleResolveResult}\n */\nfunction validateResolve(specifier, context, result) {\n const { url, format, importAttributes } = result;\n if (typeof url !== 'string') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a URL string',\n 'resolve',\n 'url',\n url,\n );\n }\n\n if (format && typeof format !== 'string') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string',\n 'resolve',\n 'format',\n format,\n );\n }\n\n if (importAttributes && typeof importAttributes !== 'object') {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'an object',\n 'resolve',\n 'importAttributes',\n importAttributes,\n );\n }\n\n return {\n __proto__: null,\n url,\n format,\n importAttributes,\n };\n}\n\n/**\n * @typedef {object} ModuleLoadResult\n * @property {string|undefined} format Format of the loaded module.\n * @property {string|ArrayBuffer|TypedArray} source Source code of the module.\n * @property {boolean|undefined} shortCircuit Whether the next hook has been skipped.\n */\n\n/**\n * Validate the result returned by a chain of resolve hook.\n * @param {string} url URL passed into the hooks.\n * @param {ModuleLoadContext} context Context passed into the hooks.\n * @param {ModuleLoadResult} result Result produced by load hooks.\n * @returns {ModuleLoadResult}\n */\nfunction validateLoad(url, context, result) {\n const { source, format } = result;\n // To align with module.register(), the load hooks are still invoked for\n // the builtins even though the default load step only provides null as source,\n // and any source content for builtins provided by the user hooks are ignored.\n if (!StringPrototypeStartsWith(url, 'node:') &&\n typeof result.source !== 'string' &&\n !isAnyArrayBuffer(source) &&\n !isArrayBufferView(source)) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string, an ArrayBuffer, or a TypedArray',\n 'load',\n 'source',\n source,\n );\n }\n\n if (typeof format !== 'string' && format !== undefined) {\n throw new ERR_INVALID_RETURN_PROPERTY_VALUE(\n 'a string',\n 'load',\n 'format',\n format,\n );\n }\n\n return {\n __proto__: null,\n format,\n source,\n };\n}\n\nclass ModuleResolveContext {\n /**\n * Context for the resolve hook.\n * @param {string|undefined} parentURL Parent URL.\n * @param {ImportAttributes|undefined} importAttributes Import attributes.\n * @param {string[]} conditions Conditions.\n */\n constructor(parentURL, importAttributes, conditions) {\n this.parentURL = parentURL;\n this.importAttributes = importAttributes;\n this.conditions = conditions;\n // TODO(joyeecheung): a field to differentiate between require and import?\n }\n};\n\nclass ModuleLoadContext {\n /**\n * Context for the load hook.\n * @param {string|undefined} format URL.\n * @param {ImportAttributes|undefined} importAttributes Import attributes.\n * @param {string[]} conditions Conditions.\n */\n constructor(format, importAttributes, conditions) {\n this.format = format;\n this.importAttributes = importAttributes;\n this.conditions = conditions;\n }\n};\n\nlet decoder;\n/**\n * Load module source for a url, through a hooks chain if it exists.\n * @param {string} url\n * @param {string|undefined} originalFormat\n * @param {ImportAttributes|undefined} importAttributes\n * @param {string[]} conditions\n * @param {(url: string, context: ModuleLoadContext) => ModuleLoadResult} defaultLoad\n * @returns {ModuleLoadResult}\n */\nfunction loadWithHooks(url, originalFormat, importAttributes, conditions, defaultLoad) {\n debug('loadWithHooks', url, originalFormat);\n const context = new ModuleLoadContext(originalFormat, importAttributes, conditions);\n if (loadHooks.length === 0) {\n return defaultLoad(url, context);\n }\n\n const runner = buildHooks(loadHooks, 'load', defaultLoad, validateLoad, context);\n\n const result = runner(url, context);\n const { source, format } = result;\n if (!isAnyArrayBuffer(source) && !isArrayBufferView(source)) {\n return result;\n }\n\n switch (format) {\n // Text formats:\n case undefined:\n case 'module':\n case 'commonjs':\n case 'json':\n case 'module-typescript':\n case 'commonjs-typescript':\n case 'typescript': {\n decoder ??= new (require('internal/encoding').TextDecoder)();\n result.source = decoder.decode(source);\n break;\n }\n default:\n break;\n }\n return result;\n}\n\n/**\n * Resolve module request to a url, through a hooks chain if it exists.\n * @param {string} specifier\n * @param {string|undefined} parentURL\n * @param {ImportAttributes|undefined} importAttributes\n * @param {string[]} conditions\n * @param {(specifier: string, context: ModuleResolveContext) => ModuleResolveResult} defaultResolve\n * @returns {ModuleResolveResult}\n */\nfunction resolveWithHooks(specifier, parentURL, importAttributes, conditions, defaultResolve) {\n debug('resolveWithHooks', specifier, parentURL, importAttributes);\n const context = new ModuleResolveContext(parentURL, importAttributes, conditions);\n if (resolveHooks.length === 0) {\n return defaultResolve(specifier, context);\n }\n\n const runner = buildHooks(resolveHooks, 'resolve', defaultResolve, validateResolve, context);\n\n return runner(specifier, context);\n}\n\nmodule.exports = {\n convertCJSFilenameToURL,\n convertURLToCJSFilename,\n loadHooks,\n loadWithHooks,\n registerHooks,\n resolveHooks,\n resolveWithHooks,\n};\n";
|
|
566
|
+
const INTERNAL_MODULES_TYPESCRIPT = "'use strict';\n\nconst {\n ObjectPrototypeHasOwnProperty,\n} = primordials;\nconst {\n validateBoolean,\n validateOneOf,\n validateObject,\n validateString,\n} = require('internal/validators');\nconst { assertTypeScript,\n emitExperimentalWarning,\n getLazy,\n isUnderNodeModules,\n kEmptyObject } = require('internal/util');\nconst {\n ERR_INVALID_TYPESCRIPT_SYNTAX,\n ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING,\n ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX,\n} = require('internal/errors').codes;\nconst { getOptionValue } = require('internal/options');\nconst assert = require('internal/assert');\nconst { Buffer } = require('buffer');\n\n/**\n * The TypeScript parsing mode, either 'strip-only' or 'transform'.\n * @type {function(): TypeScriptMode}\n */\nconst getTypeScriptParsingMode = getLazy(() =>\n (getOptionValue('--experimental-transform-types') ?\n (emitExperimentalWarning('Transform Types'), 'transform') : 'strip-only'),\n);\n\n/**\n * Load the TypeScript parser.\n * and returns an object with a `code` property.\n * @returns {Function} The TypeScript parser function.\n */\nconst loadTypeScriptParser = getLazy(() => {\n assertTypeScript();\n const amaro = require('internal/deps/amaro/dist/index');\n return amaro.transformSync;\n});\n\n/**\n *\n * @param {string} source the source code\n * @param {object} options the options to pass to the parser\n * @returns {TransformOutput} an object with a `code` property.\n */\nfunction parseTypeScript(source, options) {\n const parse = loadTypeScriptParser();\n try {\n return parse(source, options);\n } catch (error) {\n /**\n * Amaro v0.3.0 (from SWC v1.10.7) throws an object with `message` and `code` properties.\n * It allows us to distinguish between invalid syntax and unsupported syntax.\n */\n switch (error?.code) {\n case 'UnsupportedSyntax': {\n const unsupportedSyntaxError = new ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX(error.message);\n throw decorateErrorWithSnippet(unsupportedSyntaxError, error); /* node-do-not-add-exception-line */\n }\n case 'InvalidSyntax': {\n const invalidSyntaxError = new ERR_INVALID_TYPESCRIPT_SYNTAX(error.message);\n throw decorateErrorWithSnippet(invalidSyntaxError, error); /* node-do-not-add-exception-line */\n }\n default:\n // SWC may throw strings when something goes wrong.\n if (typeof error === 'string') { assert.fail(error); }\n assert(error != null && ObjectPrototypeHasOwnProperty(error, 'message'));\n assert.fail(error.message);\n }\n }\n}\n\n/**\n *\n * @param {Error} error the error to decorate: ERR_INVALID_TYPESCRIPT_SYNTAX, ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX\n * @param {object} amaroError the error object from amaro\n * @returns {Error} the decorated error\n */\nfunction decorateErrorWithSnippet(error, amaroError) {\n const errorHints = `${amaroError.filename}:${amaroError.startLine}\\n${amaroError.snippet}`;\n error.stack = `${errorHints}\\n${error.stack}`;\n return error;\n}\n\n/**\n * Performs type-stripping to TypeScript source code.\n * @param {string} code TypeScript code to parse.\n * @param {TransformOptions} options The configuration for type stripping.\n * @returns {string} The stripped TypeScript code.\n */\nfunction stripTypeScriptTypes(code, options = kEmptyObject) {\n emitExperimentalWarning('stripTypeScriptTypes');\n validateString(code, 'code');\n validateObject(options, 'options');\n\n const {\n sourceMap = false,\n sourceUrl = '',\n } = options;\n let { mode = 'strip' } = options;\n validateOneOf(mode, 'options.mode', ['strip', 'transform']);\n validateBoolean(sourceMap, 'options.sourceMap');\n validateString(sourceUrl, 'options.sourceUrl');\n if (mode === 'strip') {\n validateOneOf(sourceMap, 'options.sourceMap', [false, undefined]);\n // Rename mode from 'strip' to 'strip-only'.\n // The reason is to match `process.features.typescript` which returns `strip`,\n // but the parser expects `strip-only`.\n mode = 'strip-only';\n }\n\n return processTypeScriptCode(code, {\n mode,\n sourceMap,\n filename: sourceUrl,\n });\n}\n\n/**\n * Processes TypeScript code by stripping types or transforming.\n * Handles source maps if needed.\n * @param {string} code TypeScript code to process.\n * @param {object} options The configuration object.\n * @returns {string} The processed code.\n */\nfunction processTypeScriptCode(code, options) {\n const { code: transformedCode, map } = parseTypeScript(code, options);\n\n if (map) {\n return addSourceMap(transformedCode, map);\n }\n\n if (options.filename) {\n return `${transformedCode}\\n\\n//# sourceURL=${options.filename}`;\n }\n\n return transformedCode;\n}\n\n/**\n * Performs type-stripping to TypeScript source code internally.\n * It is used by internal loaders.\n * @param {string} source TypeScript code to parse.\n * @param {string} filename The filename of the source code.\n * @returns {TransformOutput} The stripped TypeScript code.\n */\nfunction stripTypeScriptModuleTypes(source, filename) {\n assert(typeof source === 'string');\n if (isUnderNodeModules(filename)) {\n throw new ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING(filename);\n }\n const options = {\n mode: getTypeScriptParsingMode(),\n sourceMap: getOptionValue('--enable-source-maps'),\n filename,\n };\n return processTypeScriptCode(source, options);\n}\n\n/**\n *\n * @param {string} code The compiled code.\n * @param {string} sourceMap The source map.\n * @returns {string} The code with the source map attached.\n */\nfunction addSourceMap(code, sourceMap) {\n // The base64 encoding should be https://datatracker.ietf.org/doc/html/rfc4648#section-4,\n // not base64url https://datatracker.ietf.org/doc/html/rfc4648#section-5. See data url\n // spec https://tools.ietf.org/html/rfc2397#section-2.\n const base64SourceMap = Buffer.from(sourceMap).toString('base64');\n return `${code}\\n\\n//# sourceMappingURL=data:application/json;base64,${base64SourceMap}`;\n}\n\nmodule.exports = {\n stripTypeScriptModuleTypes,\n stripTypeScriptTypes,\n};\n";
|
|
566
567
|
const EVENTS = "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nconst {\n ArrayPrototypeJoin,\n ArrayPrototypePop,\n ArrayPrototypePush,\n ArrayPrototypeSlice,\n ArrayPrototypeSplice,\n ArrayPrototypeUnshift,\n Boolean,\n Error,\n ErrorCaptureStackTrace,\n FunctionPrototypeBind,\n FunctionPrototypeCall,\n NumberMAX_SAFE_INTEGER,\n ObjectDefineProperties,\n ObjectDefineProperty,\n ObjectGetPrototypeOf,\n ObjectSetPrototypeOf,\n Promise,\n PromiseReject,\n PromiseResolve,\n ReflectApply,\n ReflectOwnKeys,\n String,\n StringPrototypeSplit,\n Symbol,\n SymbolAsyncIterator,\n SymbolFor,\n} = primordials;\nconst kRejection = SymbolFor('nodejs.rejection');\n\nconst { SymbolDispose, kEmptyObject, spliceOne } = require('internal/util');\n\nconst {\n inspect,\n identicalSequenceRange,\n} = require('internal/util/inspect');\n\nlet FixedQueue;\nlet kFirstEventParam;\nlet kResistStopPropagation;\n\nconst {\n AbortError,\n codes: {\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_THIS,\n ERR_UNHANDLED_ERROR,\n },\n genericNodeError,\n kEnhanceStackBeforeInspector,\n} = require('internal/errors');\n\nconst {\n validateInteger,\n validateAbortSignal,\n validateBoolean,\n validateFunction,\n validateNumber,\n validateObject,\n validateString,\n} = require('internal/validators');\nconst { addAbortListener } = require('internal/events/abort_listener');\n\nconst kCapture = Symbol('kCapture');\nconst kErrorMonitor = Symbol('events.errorMonitor');\nconst kShapeMode = Symbol('shapeMode');\nconst kMaxEventTargetListeners = Symbol('events.maxEventTargetListeners');\nconst kMaxEventTargetListenersWarned =\n Symbol('events.maxEventTargetListenersWarned');\nconst kWatermarkData = SymbolFor('nodejs.watermarkData');\n\nlet EventEmitterAsyncResource;\n// The EventEmitterAsyncResource has to be initialized lazily because event.js\n// is loaded so early in the bootstrap process, before async_hooks is available.\n//\n// This implementation was adapted straight from addaleax's\n// eventemitter-asyncresource MIT-licensed userland module.\n// https://github.com/addaleax/eventemitter-asyncresource\nfunction lazyEventEmitterAsyncResource() {\n if (EventEmitterAsyncResource === undefined) {\n const {\n AsyncResource,\n } = require('async_hooks');\n\n const kEventEmitter = Symbol('kEventEmitter');\n const kAsyncResource = Symbol('kAsyncResource');\n class EventEmitterReferencingAsyncResource extends AsyncResource {\n /**\n * @param {EventEmitter} ee\n * @param {string} [type]\n * @param {{\n * triggerAsyncId?: number,\n * requireManualDestroy?: boolean,\n * }} [options]\n */\n constructor(ee, type, options) {\n super(type, options);\n this[kEventEmitter] = ee;\n }\n\n /**\n * @type {EventEmitter}\n */\n get eventEmitter() {\n if (this[kEventEmitter] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterReferencingAsyncResource');\n return this[kEventEmitter];\n }\n }\n\n EventEmitterAsyncResource =\n class EventEmitterAsyncResource extends EventEmitter {\n /**\n * @param {{\n * name?: string,\n * triggerAsyncId?: number,\n * requireManualDestroy?: boolean,\n * }} [options]\n */\n constructor(options = undefined) {\n let name;\n if (typeof options === 'string') {\n name = options;\n options = undefined;\n } else {\n if (new.target === EventEmitterAsyncResource) {\n validateString(options?.name, 'options.name');\n }\n name = options?.name || new.target.name;\n }\n super(options);\n\n this[kAsyncResource] =\n new EventEmitterReferencingAsyncResource(this, name, options);\n }\n\n /**\n * @param {symbol,string} event\n * @param {...any} args\n * @returns {boolean}\n */\n emit(event, ...args) {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n const { asyncResource } = this;\n ArrayPrototypeUnshift(args, super.emit, this, event);\n return ReflectApply(asyncResource.runInAsyncScope, asyncResource,\n args);\n }\n\n /**\n * @returns {void}\n */\n emitDestroy() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n this.asyncResource.emitDestroy();\n }\n\n /**\n * @type {number}\n */\n get asyncId() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this.asyncResource.asyncId();\n }\n\n /**\n * @type {number}\n */\n get triggerAsyncId() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this.asyncResource.triggerAsyncId();\n }\n\n /**\n * @type {EventEmitterReferencingAsyncResource}\n */\n get asyncResource() {\n if (this[kAsyncResource] === undefined)\n throw new ERR_INVALID_THIS('EventEmitterAsyncResource');\n return this[kAsyncResource];\n }\n };\n }\n return EventEmitterAsyncResource;\n}\n\n/**\n * Creates a new `EventEmitter` instance.\n * @param {{ captureRejections?: boolean; }} [opts]\n * @constructs {EventEmitter}\n */\nfunction EventEmitter(opts) {\n EventEmitter.init.call(this, opts);\n}\nmodule.exports = EventEmitter;\nmodule.exports.addAbortListener = addAbortListener;\nmodule.exports.once = once;\nmodule.exports.on = on;\nmodule.exports.getEventListeners = getEventListeners;\nmodule.exports.getMaxListeners = getMaxListeners;\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.usingDomains = false;\n\nEventEmitter.captureRejectionSymbol = kRejection;\nObjectDefineProperty(EventEmitter, 'captureRejections', {\n __proto__: null,\n get() {\n return EventEmitter.prototype[kCapture];\n },\n set(value) {\n validateBoolean(value, 'EventEmitter.captureRejections');\n\n EventEmitter.prototype[kCapture] = value;\n },\n enumerable: true,\n});\n\nObjectDefineProperty(EventEmitter, 'EventEmitterAsyncResource', {\n __proto__: null,\n enumerable: true,\n get: lazyEventEmitterAsyncResource,\n set: undefined,\n configurable: true,\n});\n\nEventEmitter.errorMonitor = kErrorMonitor;\n\n// The default for captureRejections is false\nObjectDefineProperty(EventEmitter.prototype, kCapture, {\n __proto__: null,\n value: false,\n writable: true,\n enumerable: false,\n});\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nlet defaultMaxListeners = 10;\nlet isEventTarget;\n\nfunction checkListener(listener) {\n validateFunction(listener, 'listener');\n}\n\nObjectDefineProperty(EventEmitter, 'defaultMaxListeners', {\n __proto__: null,\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n validateNumber(arg, 'defaultMaxListeners', 0);\n defaultMaxListeners = arg;\n },\n});\n\nObjectDefineProperties(EventEmitter, {\n kMaxEventTargetListeners: {\n __proto__: null,\n value: kMaxEventTargetListeners,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n kMaxEventTargetListenersWarned: {\n __proto__: null,\n value: kMaxEventTargetListenersWarned,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n});\n\n/**\n * Sets the max listeners.\n * @param {number} n\n * @param {EventTarget[] | EventEmitter[]} [eventTargets]\n * @returns {void}\n */\nEventEmitter.setMaxListeners =\n function(n = defaultMaxListeners, ...eventTargets) {\n validateNumber(n, 'setMaxListeners', 0);\n if (eventTargets.length === 0) {\n defaultMaxListeners = n;\n } else {\n if (isEventTarget === undefined)\n isEventTarget = require('internal/event_target').isEventTarget;\n\n for (let i = 0; i < eventTargets.length; i++) {\n const target = eventTargets[i];\n if (isEventTarget(target)) {\n target[kMaxEventTargetListeners] = n;\n target[kMaxEventTargetListenersWarned] = false;\n } else if (typeof target.setMaxListeners === 'function') {\n target.setMaxListeners(n);\n } else {\n throw new ERR_INVALID_ARG_TYPE(\n 'eventTargets',\n ['EventEmitter', 'EventTarget'],\n target);\n }\n }\n }\n };\n\n// If you're updating this function definition, please also update any\n// re-definitions, such as the one in the Domain module (lib/domain.js).\nEventEmitter.init = function(opts) {\n\n if (this._events === undefined ||\n this._events === ObjectGetPrototypeOf(this)._events) {\n this._events = { __proto__: null };\n this._eventsCount = 0;\n this[kShapeMode] = false;\n } else {\n this[kShapeMode] = true;\n }\n\n this._maxListeners ||= undefined;\n\n\n if (opts?.captureRejections) {\n validateBoolean(opts.captureRejections, 'options.captureRejections');\n this[kCapture] = Boolean(opts.captureRejections);\n } else {\n // Assigning the kCapture property directly saves an expensive\n // prototype lookup in a very sensitive hot path.\n this[kCapture] = EventEmitter.prototype[kCapture];\n }\n};\n\nfunction addCatch(that, promise, type, args) {\n if (!that[kCapture]) {\n return;\n }\n\n // Handle Promises/A+ spec, then could be a getter\n // that throws on second use.\n try {\n const then = promise.then;\n\n if (typeof then === 'function') {\n then.call(promise, undefined, function(err) {\n // The callback is called with nextTick to avoid a follow-up\n // rejection from this promise.\n process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args);\n });\n }\n } catch (err) {\n that.emit('error', err);\n }\n}\n\nfunction emitUnhandledRejectionOrErr(ee, err, type, args) {\n if (typeof ee[kRejection] === 'function') {\n ee[kRejection](err, type, ...args);\n } else {\n // We have to disable the capture rejections mechanism, otherwise\n // we might end up in an infinite loop.\n const prev = ee[kCapture];\n\n // If the error handler throws, it is not catchable and it\n // will end up in 'uncaughtException'. We restore the previous\n // value of kCapture in case the uncaughtException is present\n // and the exception is handled.\n try {\n ee[kCapture] = false;\n ee.emit('error', err);\n } finally {\n ee[kCapture] = prev;\n }\n }\n}\n\n/**\n * Increases the max listeners of the event emitter.\n * @param {number} n\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n validateNumber(n, 'setMaxListeners', 0);\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\n/**\n * Returns the current max listener value for the event emitter.\n * @returns {number}\n */\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nfunction enhanceStackTrace(err, own) {\n let ctorInfo = '';\n try {\n const { name } = this.constructor;\n if (name !== 'EventEmitter')\n ctorInfo = ` on ${name} instance`;\n } catch {\n // Continue regardless of error.\n }\n const sep = `\\nEmitted 'error' event${ctorInfo} at:\\n`;\n\n const errStack = ArrayPrototypeSlice(\n StringPrototypeSplit(err.stack, '\\n'), 1);\n const ownStack = ArrayPrototypeSlice(\n StringPrototypeSplit(own.stack, '\\n'), 1);\n\n const { len, offset } = identicalSequenceRange(ownStack, errStack);\n if (len > 0) {\n ArrayPrototypeSplice(ownStack, offset + 1, len - 2,\n ' [... lines matching original stack trace ...]');\n }\n\n return err.stack + sep + ArrayPrototypeJoin(ownStack, '\\n');\n}\n\n/**\n * Synchronously calls each of the listeners registered\n * for the event.\n * @param {string | symbol} type\n * @param {...any} [args]\n * @returns {boolean}\n */\nEventEmitter.prototype.emit = function emit(type, ...args) {\n let doError = (type === 'error');\n\n const events = this._events;\n if (events !== undefined) {\n if (doError && events[kErrorMonitor] !== undefined)\n this.emit(kErrorMonitor, ...args);\n doError &&= events.error === undefined;\n } else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n let er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n try {\n const capture = {};\n ErrorCaptureStackTrace(capture, EventEmitter.prototype.emit);\n ObjectDefineProperty(er, kEnhanceStackBeforeInspector, {\n __proto__: null,\n value: FunctionPrototypeBind(enhanceStackTrace, this, er, capture),\n configurable: true,\n });\n } catch {\n // Continue regardless of error.\n }\n\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n\n let stringifiedEr;\n try {\n stringifiedEr = inspect(er);\n } catch {\n stringifiedEr = er;\n }\n\n // At least give some kind of context to the user\n const err = new ERR_UNHANDLED_ERROR(stringifiedEr);\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n const handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n const result = handler.apply(this, args);\n\n // We check if result is undefined first because that\n // is the most common case so we do not pay any perf\n // penalty\n if (result !== undefined && result !== null) {\n addCatch(this, result, type, args);\n }\n } else {\n const len = handler.length;\n const listeners = arrayClone(handler);\n for (let i = 0; i < len; ++i) {\n const result = listeners[i].apply(this, args);\n\n // We check if result is undefined first because that\n // is the most common case so we do not pay any perf\n // penalty.\n // This code is duplicated because extracting it away\n // would make it non-inlineable.\n if (result !== undefined && result !== null) {\n addCatch(this, result, type, args);\n }\n }\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n let m;\n let events;\n let existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = { __proto__: null };\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ?? listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n const w = genericNodeError(\n `Possible EventEmitter memory leak detected. ${existing.length} ${String(type)} listeners ` +\n `added to ${inspect(target, { depth: -1 })}. MaxListeners is ${m}. Use emitter.setMaxListeners() to increase limit`,\n { name: 'MaxListenersExceededWarning', emitter: target, type: type, count: existing.length });\n process.emitWarning(w);\n }\n }\n\n return target;\n}\n\n/**\n * Adds a listener to the event emitter.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\n/**\n * Adds the `listener` function to the beginning of\n * the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n const state = { fired: false, wrapFn: undefined, target, type, listener };\n const wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\n/**\n * Adds a one-time `listener` function to the event emitter.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\n/**\n * Adds a one-time `listener` function to the beginning of\n * the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n/**\n * Removes the specified `listener` from the listeners array.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n checkListener(listener);\n\n const events = this._events;\n if (events === undefined)\n return this;\n\n const list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n this._eventsCount -= 1;\n\n if (this[kShapeMode]) {\n events[type] = undefined;\n } else if (this._eventsCount === 0) {\n this._events = { __proto__: null };\n } else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n let position = -1;\n\n for (let i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\n/**\n * Removes all listeners from the event emitter. (Only\n * removes listeners for a specific event name if specified\n * as `type`).\n * @param {string | symbol} [type]\n * @returns {EventEmitter}\n */\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n const events = this._events;\n if (events === undefined)\n return this;\n\n // Not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = { __proto__: null };\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = { __proto__: null };\n else\n delete events[type];\n }\n this[kShapeMode] = false;\n return this;\n }\n\n // Emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (const key of ReflectOwnKeys(events)) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = { __proto__: null };\n this._eventsCount = 0;\n this[kShapeMode] = false;\n return this;\n }\n\n const listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (let i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n const events = target._events;\n\n if (events === undefined)\n return [];\n\n const evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener);\n}\n\n/**\n * Returns a copy of the array of listeners for the event name\n * specified as `type`.\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\n/**\n * Returns a copy of the array of listeners and wrappers for\n * the event name specified as `type`.\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\n/**\n * Returns the number of listeners listening to the event name\n * specified as `type`.\n * @deprecated since v3.2.0\n * @param {EventEmitter} emitter\n * @param {string | symbol} type\n * @returns {number}\n */\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n }\n return FunctionPrototypeCall(listenerCount, emitter, type);\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\n\n/**\n * Returns the number of listeners listening to event name\n * specified as `type`.\n * @param {string | symbol} type\n * @param {Function} listener\n * @returns {number}\n */\nfunction listenerCount(type, listener) {\n const events = this._events;\n\n if (events !== undefined) {\n const evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n if (listener != null) {\n return listener === evlistener || listener === evlistener.listener ? 1 : 0;\n }\n\n return 1;\n } else if (evlistener !== undefined) {\n if (listener != null) {\n let matching = 0;\n\n for (let i = 0, l = evlistener.length; i < l; i++) {\n if (evlistener[i] === listener || evlistener[i].listener === listener) {\n matching++;\n }\n }\n\n return matching;\n }\n\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\n/**\n * Returns an array listing the events for which\n * the emitter has registered listeners.\n * @returns {(string | symbol)[]}\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr) {\n // At least since V8 8.3, this implementation is faster than the previous\n // which always used a simple for-loop\n switch (arr.length) {\n case 2: return [arr[0], arr[1]];\n case 3: return [arr[0], arr[1], arr[2]];\n case 4: return [arr[0], arr[1], arr[2], arr[3]];\n case 5: return [arr[0], arr[1], arr[2], arr[3], arr[4]];\n case 6: return [arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]];\n }\n return ArrayPrototypeSlice(arr);\n}\n\nfunction unwrapListeners(arr) {\n const ret = arrayClone(arr);\n for (let i = 0; i < ret.length; ++i) {\n const orig = ret[i].listener;\n if (typeof orig === 'function')\n ret[i] = orig;\n }\n return ret;\n}\n\n/**\n * Returns a copy of the array of listeners for the event name\n * specified as `type`.\n * @param {EventEmitter | EventTarget} emitterOrTarget\n * @param {string | symbol} type\n * @returns {Function[]}\n */\nfunction getEventListeners(emitterOrTarget, type) {\n // First check if EventEmitter\n if (typeof emitterOrTarget.listeners === 'function') {\n return emitterOrTarget.listeners(type);\n }\n // Require event target lazily to avoid always loading it\n const { isEventTarget, kEvents } = require('internal/event_target');\n if (isEventTarget(emitterOrTarget)) {\n const root = emitterOrTarget[kEvents].get(type);\n const listeners = [];\n let handler = root?.next;\n while (handler?.listener !== undefined) {\n const listener = handler.listener?.deref ?\n handler.listener.deref() : handler.listener;\n listeners.push(listener);\n handler = handler.next;\n }\n return listeners;\n }\n throw new ERR_INVALID_ARG_TYPE('emitter',\n ['EventEmitter', 'EventTarget'],\n emitterOrTarget);\n}\n\n/**\n * Returns the max listeners set.\n * @param {EventEmitter | EventTarget} emitterOrTarget\n * @returns {number}\n */\nfunction getMaxListeners(emitterOrTarget) {\n if (typeof emitterOrTarget?.getMaxListeners === 'function') {\n return _getMaxListeners(emitterOrTarget);\n } else if (typeof emitterOrTarget?.[kMaxEventTargetListeners] === 'number') {\n return emitterOrTarget[kMaxEventTargetListeners];\n }\n\n throw new ERR_INVALID_ARG_TYPE('emitter',\n ['EventEmitter', 'EventTarget'],\n emitterOrTarget);\n}\n\n/**\n * Creates a `Promise` that is fulfilled when the emitter\n * emits the given event.\n * @param {EventEmitter} emitter\n * @param {string | symbol} name\n * @param {{ signal: AbortSignal; }} [options]\n * @returns {Promise}\n */\nasync function once(emitter, name, options = kEmptyObject) {\n validateObject(options, 'options');\n const { signal } = options;\n validateAbortSignal(signal, 'options.signal');\n if (signal?.aborted)\n throw new AbortError(undefined, { cause: signal.reason });\n return new Promise((resolve, reject) => {\n const errorListener = (err) => {\n emitter.removeListener(name, resolver);\n if (signal != null) {\n eventTargetAgnosticRemoveListener(signal, 'abort', abortListener);\n }\n reject(err);\n };\n const resolver = (...args) => {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n if (signal != null) {\n eventTargetAgnosticRemoveListener(signal, 'abort', abortListener);\n }\n resolve(args);\n };\n\n kResistStopPropagation ??= require('internal/event_target').kResistStopPropagation;\n const opts = { __proto__: null, once: true, [kResistStopPropagation]: true };\n eventTargetAgnosticAddListener(emitter, name, resolver, opts);\n if (name !== 'error' && typeof emitter.once === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we listen to `error` events only on EventEmitters.\n emitter.once('error', errorListener);\n }\n function abortListener() {\n eventTargetAgnosticRemoveListener(emitter, name, resolver);\n eventTargetAgnosticRemoveListener(emitter, 'error', errorListener);\n reject(new AbortError(undefined, { cause: signal?.reason }));\n }\n if (signal != null) {\n eventTargetAgnosticAddListener(\n signal, 'abort', abortListener, { __proto__: null, once: true, [kResistStopPropagation]: true });\n }\n });\n}\n\nconst AsyncIteratorPrototype = ObjectGetPrototypeOf(\n ObjectGetPrototypeOf(async function* () {}).prototype);\n\nfunction createIterResult(value, done) {\n return { value, done };\n}\n\nfunction eventTargetAgnosticRemoveListener(emitter, name, listener, flags) {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener(name, listener);\n } else if (typeof emitter.removeEventListener === 'function') {\n emitter.removeEventListener(name, listener, flags);\n } else {\n throw new ERR_INVALID_ARG_TYPE('emitter', 'EventEmitter', emitter);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags?.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n emitter.addEventListener(name, listener, flags);\n } else {\n throw new ERR_INVALID_ARG_TYPE('emitter', 'EventEmitter', emitter);\n }\n}\n\n/**\n * Returns an `AsyncIterator` that iterates `event` events.\n * @param {EventEmitter} emitter\n * @param {string | symbol} event\n * @param {{\n * signal: AbortSignal;\n * close?: string[];\n * highWaterMark?: number,\n * lowWaterMark?: number\n * }} [options]\n * @returns {AsyncIterator}\n */\nfunction on(emitter, event, options = kEmptyObject) {\n // Parameters validation\n validateObject(options, 'options');\n const signal = options.signal;\n validateAbortSignal(signal, 'options.signal');\n if (signal?.aborted)\n throw new AbortError(undefined, { cause: signal.reason });\n // Support both highWaterMark and highWatermark for backward compatibility\n const highWatermark = options.highWaterMark ?? options.highWatermark ?? NumberMAX_SAFE_INTEGER;\n validateInteger(highWatermark, 'options.highWaterMark', 1);\n // Support both lowWaterMark and lowWatermark for backward compatibility\n const lowWatermark = options.lowWaterMark ?? options.lowWatermark ?? 1;\n validateInteger(lowWatermark, 'options.lowWaterMark', 1);\n\n // Preparing controlling queues and variables\n FixedQueue ??= require('internal/fixed_queue');\n const unconsumedEvents = new FixedQueue();\n const unconsumedPromises = new FixedQueue();\n let paused = false;\n let error = null;\n let finished = false;\n let size = 0;\n\n const iterator = ObjectSetPrototypeOf({\n next() {\n // First, we consume all unread events\n if (size) {\n const value = unconsumedEvents.shift();\n size--;\n if (paused && size < lowWatermark) {\n emitter.resume();\n paused = false;\n }\n return PromiseResolve(createIterResult(value, false));\n }\n\n // Then we error, if an error happened\n // This happens one time if at all, because after 'error'\n // we stop listening\n if (error) {\n const p = PromiseReject(error);\n // Only the first element errors\n error = null;\n return p;\n }\n\n // If the iterator is finished, resolve to done\n if (finished) return closeHandler();\n\n // Wait until an event happens\n return new Promise(function(resolve, reject) {\n unconsumedPromises.push({ resolve, reject });\n });\n },\n\n return() {\n return closeHandler();\n },\n\n throw(err) {\n if (!err || !(err instanceof Error)) {\n throw new ERR_INVALID_ARG_TYPE('EventEmitter.AsyncIterator',\n 'Error', err);\n }\n errorHandler(err);\n },\n [SymbolAsyncIterator]() {\n return this;\n },\n [kWatermarkData]: {\n /**\n * The current queue size\n */\n get size() {\n return size;\n },\n /**\n * The low watermark. The emitter is resumed every time size is lower than it\n */\n get low() {\n return lowWatermark;\n },\n /**\n * The high watermark. The emitter is paused every time size is higher than it\n */\n get high() {\n return highWatermark;\n },\n /**\n * It checks whether the emitter is paused by the watermark controller or not\n */\n get isPaused() {\n return paused;\n },\n },\n }, AsyncIteratorPrototype);\n\n // Adding event handlers\n const { addEventListener, removeAll } = listenersController();\n kFirstEventParam ??= require('internal/events/symbols').kFirstEventParam;\n addEventListener(emitter, event, options[kFirstEventParam] ? eventHandler : function(...args) {\n return eventHandler(args);\n });\n if (event !== 'error' && typeof emitter.on === 'function') {\n addEventListener(emitter, 'error', errorHandler);\n }\n const closeEvents = options?.close;\n if (closeEvents?.length) {\n for (let i = 0; i < closeEvents.length; i++) {\n addEventListener(emitter, closeEvents[i], closeHandler);\n }\n }\n\n const abortListenerDisposable = signal ? addAbortListener(signal, abortListener) : null;\n\n return iterator;\n\n function abortListener() {\n errorHandler(new AbortError(undefined, { cause: signal?.reason }));\n }\n\n function eventHandler(value) {\n if (unconsumedPromises.isEmpty()) {\n size++;\n if (!paused && size > highWatermark) {\n paused = true;\n emitter.pause();\n }\n unconsumedEvents.push(value);\n } else unconsumedPromises.shift().resolve(createIterResult(value, false));\n }\n\n function errorHandler(err) {\n if (unconsumedPromises.isEmpty()) error = err;\n else unconsumedPromises.shift().reject(err);\n\n closeHandler();\n }\n\n function closeHandler() {\n abortListenerDisposable?.[SymbolDispose]();\n removeAll();\n finished = true;\n const doneResult = createIterResult(undefined, true);\n while (!unconsumedPromises.isEmpty()) {\n unconsumedPromises.shift().resolve(doneResult);\n }\n\n return PromiseResolve(doneResult);\n }\n}\n\nfunction listenersController() {\n const listeners = [];\n\n return {\n addEventListener(emitter, event, handler, flags) {\n eventTargetAgnosticAddListener(emitter, event, handler, flags);\n ArrayPrototypePush(listeners, [emitter, event, handler, flags]);\n },\n removeAll() {\n while (listeners.length > 0) {\n ReflectApply(eventTargetAgnosticRemoveListener, undefined, ArrayPrototypePop(listeners));\n }\n },\n };\n}\n";
|
|
567
568
|
const INTERNAL_CONSTANTS = "'use strict';\n\nconst isWindows = process.platform === 'win32';\n\nmodule.exports = {\n // Alphabet chars.\n CHAR_UPPERCASE_A: 65, /* A */\n CHAR_LOWERCASE_A: 97, /* a */\n CHAR_UPPERCASE_Z: 90, /* Z */\n CHAR_LOWERCASE_Z: 122, /* z */\n CHAR_UPPERCASE_C: 67, /* C */\n CHAR_LOWERCASE_B: 98, /* b */\n CHAR_LOWERCASE_E: 101, /* e */\n CHAR_LOWERCASE_N: 110, /* n */\n\n // Non-alphabetic chars.\n CHAR_DOT: 46, /* . */\n CHAR_FORWARD_SLASH: 47, /* / */\n CHAR_BACKWARD_SLASH: 92, /* \\ */\n CHAR_VERTICAL_LINE: 124, /* | */\n CHAR_COLON: 58, /* : */\n CHAR_QUESTION_MARK: 63, /* ? */\n CHAR_UNDERSCORE: 95, /* _ */\n CHAR_LINE_FEED: 10, /* \\n */\n CHAR_CARRIAGE_RETURN: 13, /* \\r */\n CHAR_TAB: 9, /* \\t */\n CHAR_FORM_FEED: 12, /* \\f */\n CHAR_EXCLAMATION_MARK: 33, /* ! */\n CHAR_HASH: 35, /* # */\n CHAR_SPACE: 32, /* */\n CHAR_NO_BREAK_SPACE: 160, /* \\u00A0 */\n CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \\uFEFF */\n CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */\n CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */\n CHAR_LEFT_ANGLE_BRACKET: 60, /* < */\n CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */\n CHAR_LEFT_CURLY_BRACKET: 123, /* { */\n CHAR_RIGHT_CURLY_BRACKET: 125, /* } */\n CHAR_HYPHEN_MINUS: 45, /* - */\n CHAR_PLUS: 43, /* + */\n CHAR_DOUBLE_QUOTE: 34, /* \" */\n CHAR_SINGLE_QUOTE: 39, /* ' */\n CHAR_PERCENT: 37, /* % */\n CHAR_SEMICOLON: 59, /* ; */\n CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */\n CHAR_GRAVE_ACCENT: 96, /* ` */\n CHAR_AT: 64, /* @ */\n CHAR_AMPERSAND: 38, /* & */\n CHAR_EQUAL: 61, /* = */\n\n // Digits\n CHAR_0: 48, /* 0 */\n CHAR_9: 57, /* 9 */\n\n EOL: isWindows ? '\\r\\n' : '\\n',\n};\n";
|
|
568
569
|
const INTERNAL_MIME = "'use strict';\n\nconst {\n FunctionPrototypeCall,\n ObjectDefineProperty,\n RegExpPrototypeExec,\n SafeMap,\n SafeStringPrototypeSearch,\n StringPrototypeCharAt,\n StringPrototypeIndexOf,\n StringPrototypeSlice,\n StringPrototypeToLowerCase,\n SymbolIterator,\n} = primordials;\nconst {\n ERR_INVALID_MIME_SYNTAX,\n} = require('internal/errors').codes;\n\nconst NOT_HTTP_TOKEN_CODE_POINT = /[^!#$%&'*+\\-.^_`|~A-Za-z0-9]/g;\nconst NOT_HTTP_QUOTED_STRING_CODE_POINT = /[^\\t\\u0020-~\\u0080-\\u00FF]/g;\n\nconst END_BEGINNING_WHITESPACE = /[^\\r\\n\\t ]|$/;\nconst START_ENDING_WHITESPACE = /[\\r\\n\\t ]*$/;\n\nfunction toASCIILower(str) {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n result += char >= 'A' && char <= 'Z' ?\n StringPrototypeToLowerCase(char) :\n char;\n }\n return result;\n}\n\nconst SOLIDUS = '/';\nconst SEMICOLON = ';';\n\nfunction parseTypeAndSubtype(str) {\n // Skip only HTTP whitespace from start\n let position = SafeStringPrototypeSearch(str, END_BEGINNING_WHITESPACE);\n // read until '/'\n const typeEnd = StringPrototypeIndexOf(str, SOLIDUS, position);\n const trimmedType = typeEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, typeEnd);\n const invalidTypeIndex = SafeStringPrototypeSearch(trimmedType,\n NOT_HTTP_TOKEN_CODE_POINT);\n if (trimmedType === '' || invalidTypeIndex !== -1 || typeEnd === -1) {\n throw new ERR_INVALID_MIME_SYNTAX('type', str, invalidTypeIndex);\n }\n // skip type and '/'\n position = typeEnd + 1;\n const type = toASCIILower(trimmedType);\n // read until ';'\n const subtypeEnd = StringPrototypeIndexOf(str, SEMICOLON, position);\n const rawSubtype = subtypeEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, subtypeEnd);\n position += rawSubtype.length;\n if (subtypeEnd !== -1) {\n // skip ';'\n position += 1;\n }\n const trimmedSubtype = StringPrototypeSlice(\n rawSubtype,\n 0,\n SafeStringPrototypeSearch(rawSubtype, START_ENDING_WHITESPACE));\n const invalidSubtypeIndex = SafeStringPrototypeSearch(trimmedSubtype,\n NOT_HTTP_TOKEN_CODE_POINT);\n if (trimmedSubtype === '' || invalidSubtypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('subtype', str, invalidSubtypeIndex);\n }\n const subtype = toASCIILower(trimmedSubtype);\n return [\n type,\n subtype,\n position,\n ];\n}\n\nconst EQUALS_SEMICOLON_OR_END = /[;=]|$/;\nconst QUOTED_VALUE_PATTERN = /^(?:([\\\\]$)|[\\\\][\\s\\S]|[^\"])*(?:(\")|$)/u;\n\nfunction removeBackslashes(str) {\n let ret = '';\n // We stop at str.length - 1 because we want to look ahead one character.\n let i;\n for (i = 0; i < str.length - 1; i++) {\n const c = str[i];\n if (c === '\\\\') {\n i++;\n ret += str[i];\n } else {\n ret += c;\n }\n }\n // We add the last character if we didn't skip to it.\n if (i === str.length - 1) {\n ret += str[i];\n }\n return ret;\n}\n\n\nfunction escapeQuoteOrSolidus(str) {\n let result = '';\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n result += (char === '\"' || char === '\\\\') ? `\\\\${char}` : char;\n }\n return result;\n}\n\nconst encode = (value) => {\n if (value.length === 0) return '\"\"';\n const encode = SafeStringPrototypeSearch(value, NOT_HTTP_TOKEN_CODE_POINT) !== -1;\n if (!encode) return value;\n const escaped = escapeQuoteOrSolidus(value);\n return `\"${escaped}\"`;\n};\n\nclass MIMEParams {\n #data = new SafeMap();\n // We set the flag the MIMEParams instance as processed on initialization\n // to defer the parsing of a potentially large string.\n #processed = true;\n #string = null;\n\n /**\n * Used to instantiate a MIMEParams object within the MIMEType class and\n * to allow it to be parsed lazily.\n */\n static instantiateMimeParams(str) {\n const instance = new MIMEParams();\n instance.#string = str;\n instance.#processed = false;\n return instance;\n }\n\n delete(name) {\n this.#parse();\n this.#data.delete(name);\n }\n\n get(name) {\n this.#parse();\n const data = this.#data;\n if (data.has(name)) {\n return data.get(name);\n }\n return null;\n }\n\n has(name) {\n this.#parse();\n return this.#data.has(name);\n }\n\n set(name, value) {\n this.#parse();\n const data = this.#data;\n name = `${name}`;\n value = `${value}`;\n const invalidNameIndex = SafeStringPrototypeSearch(name, NOT_HTTP_TOKEN_CODE_POINT);\n if (name.length === 0 || invalidNameIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX(\n 'parameter name',\n name,\n invalidNameIndex,\n );\n }\n const invalidValueIndex = SafeStringPrototypeSearch(\n value,\n NOT_HTTP_QUOTED_STRING_CODE_POINT);\n if (invalidValueIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX(\n 'parameter value',\n value,\n invalidValueIndex,\n );\n }\n data.set(name, value);\n }\n\n *entries() {\n this.#parse();\n yield* this.#data.entries();\n }\n\n *keys() {\n this.#parse();\n yield* this.#data.keys();\n }\n\n *values() {\n this.#parse();\n yield* this.#data.values();\n }\n\n toString() {\n this.#parse();\n let ret = '';\n for (const { 0: key, 1: value } of this.#data) {\n const encoded = encode(value);\n // Ensure they are separated\n if (ret.length) ret += ';';\n ret += `${key}=${encoded}`;\n }\n return ret;\n }\n\n // Used to act as a friendly class to stringifying stuff\n // not meant to be exposed to users, could inject invalid values\n #parse() {\n if (this.#processed) return; // already parsed\n const paramsMap = this.#data;\n let position = 0;\n const str = this.#string;\n const endOfSource = SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n START_ENDING_WHITESPACE,\n ) + position;\n while (position < endOfSource) {\n // Skip any whitespace before parameter\n position += SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n END_BEGINNING_WHITESPACE,\n );\n // Read until ';' or '='\n const afterParameterName = SafeStringPrototypeSearch(\n StringPrototypeSlice(str, position),\n EQUALS_SEMICOLON_OR_END,\n ) + position;\n const parameterString = toASCIILower(\n StringPrototypeSlice(str, position, afterParameterName),\n );\n position = afterParameterName;\n // If we found a terminating character\n if (position < endOfSource) {\n // Safe to use because we never do special actions for surrogate pairs\n const char = StringPrototypeCharAt(str, position);\n // Skip the terminating character\n position += 1;\n // Ignore parameters without values\n if (char === ';') {\n continue;\n }\n }\n // If we are at end of the string, it cannot have a value\n if (position >= endOfSource) break;\n // Safe to use because we never do special actions for surrogate pairs\n const char = StringPrototypeCharAt(str, position);\n let parameterValue = null;\n if (char === '\"') {\n // Handle quoted-string form of values\n // skip '\"'\n position += 1;\n // Find matching closing '\"' or end of string\n // use $1 to see if we terminated on unmatched '\\'\n // use $2 to see if we terminated on a matching '\"'\n // so we can skip the last char in either case\n const insideMatch = RegExpPrototypeExec(\n QUOTED_VALUE_PATTERN,\n StringPrototypeSlice(str, position));\n position += insideMatch[0].length;\n // Skip including last character if an unmatched '\\' or '\"' during\n // unescape\n const inside = insideMatch[1] || insideMatch[2] ?\n StringPrototypeSlice(insideMatch[0], 0, -1) :\n insideMatch[0];\n // Unescape '\\' quoted characters\n parameterValue = removeBackslashes(inside);\n // If we did have an unmatched '\\' add it back to the end\n if (insideMatch[1]) parameterValue += '\\\\';\n } else {\n // Handle the normal parameter value form\n const valueEnd = StringPrototypeIndexOf(str, SEMICOLON, position);\n const rawValue = valueEnd === -1 ?\n StringPrototypeSlice(str, position) :\n StringPrototypeSlice(str, position, valueEnd);\n position += rawValue.length;\n const trimmedValue = StringPrototypeSlice(\n rawValue,\n 0,\n SafeStringPrototypeSearch(rawValue, START_ENDING_WHITESPACE),\n );\n // Ignore parameters without values\n if (trimmedValue === '') continue;\n parameterValue = trimmedValue;\n }\n if (\n parameterString !== '' &&\n SafeStringPrototypeSearch(parameterString,\n NOT_HTTP_TOKEN_CODE_POINT) === -1 &&\n SafeStringPrototypeSearch(parameterValue,\n NOT_HTTP_QUOTED_STRING_CODE_POINT) === -1 &&\n paramsMap.has(parameterString) === false\n ) {\n paramsMap.set(parameterString, parameterValue);\n }\n position++;\n }\n this.#data = paramsMap;\n this.#processed = true;\n }\n}\nconst MIMEParamsStringify = MIMEParams.prototype.toString;\nObjectDefineProperty(MIMEParams.prototype, SymbolIterator, {\n __proto__: null,\n configurable: true,\n value: MIMEParams.prototype.entries,\n writable: true,\n});\nObjectDefineProperty(MIMEParams.prototype, 'toJSON', {\n __proto__: null,\n configurable: true,\n value: MIMEParamsStringify,\n writable: true,\n});\n\nconst { instantiateMimeParams } = MIMEParams;\ndelete MIMEParams.instantiateMimeParams;\n\nclass MIMEType {\n #type;\n #subtype;\n #parameters;\n constructor(string) {\n string = `${string}`;\n const data = parseTypeAndSubtype(string);\n this.#type = data[0];\n this.#subtype = data[1];\n this.#parameters = instantiateMimeParams(StringPrototypeSlice(string, data[2]));\n }\n\n get type() {\n return this.#type;\n }\n\n set type(v) {\n v = `${v}`;\n const invalidTypeIndex = SafeStringPrototypeSearch(v, NOT_HTTP_TOKEN_CODE_POINT);\n if (v.length === 0 || invalidTypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('type', v, invalidTypeIndex);\n }\n this.#type = toASCIILower(v);\n }\n\n get subtype() {\n return this.#subtype;\n }\n\n set subtype(v) {\n v = `${v}`;\n const invalidSubtypeIndex = SafeStringPrototypeSearch(v, NOT_HTTP_TOKEN_CODE_POINT);\n if (v.length === 0 || invalidSubtypeIndex !== -1) {\n throw new ERR_INVALID_MIME_SYNTAX('subtype', v, invalidSubtypeIndex);\n }\n this.#subtype = toASCIILower(v);\n }\n\n get essence() {\n return `${this.#type}/${this.#subtype}`;\n }\n\n get params() {\n return this.#parameters;\n }\n\n toString() {\n let ret = `${this.#type}/${this.#subtype}`;\n const paramStr = FunctionPrototypeCall(MIMEParamsStringify, this.#parameters);\n if (paramStr.length) ret += `;${paramStr}`;\n return ret;\n }\n}\nObjectDefineProperty(MIMEType.prototype, 'toJSON', {\n __proto__: null,\n configurable: true,\n value: MIMEType.prototype.toString,\n writable: true,\n});\n\nmodule.exports = {\n MIMEParams,\n MIMEType,\n};\n";
|
|
@@ -4520,6 +4521,7 @@ const NODE_LIB_SOURCES = {
|
|
|
4520
4521
|
"internal/events/abort_listener": INTERNAL_ABORT_LISTENER,
|
|
4521
4522
|
"internal/child_process/serialization": INTERNAL_CHILD_PROCESS_SERIALIZATION,
|
|
4522
4523
|
"internal/modules/customization_hooks": INTERNAL_MODULES_CUSTOMIZATION_HOOKS,
|
|
4524
|
+
"internal/modules/typescript": INTERNAL_MODULES_TYPESCRIPT,
|
|
4523
4525
|
"events": EVENTS,
|
|
4524
4526
|
"internal/constants": INTERNAL_CONSTANTS,
|
|
4525
4527
|
"internal/mime": INTERNAL_MIME,
|
|
@@ -4906,10 +4908,21 @@ const optionValues = {
|
|
|
4906
4908
|
"--experimental-print-required-tla": false,
|
|
4907
4909
|
"--max-http-header-size": 16 * 1024,
|
|
4908
4910
|
"--insecure-http-parser": false,
|
|
4909
|
-
"--enable-source-maps": false
|
|
4911
|
+
"--enable-source-maps": false,
|
|
4912
|
+
"--experimental-transform-types": false
|
|
4910
4913
|
};
|
|
4914
|
+
let optionOverrides = null;
|
|
4915
|
+
function withOptionValues(overrides, fn) {
|
|
4916
|
+
const previous = optionOverrides;
|
|
4917
|
+
optionOverrides = { ...previous ?? {}, ...overrides };
|
|
4918
|
+
try {
|
|
4919
|
+
return fn();
|
|
4920
|
+
} finally {
|
|
4921
|
+
optionOverrides = previous;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4911
4924
|
const internalOptions = {
|
|
4912
|
-
getOptionValue: (name) => optionValues[name],
|
|
4925
|
+
getOptionValue: (name) => optionOverrides !== null && name in optionOverrides ? optionOverrides[name] : optionValues[name],
|
|
4913
4926
|
getEmbedderOptions: () => ({ shouldNotRegisterESMLoader: false, noGlobalSearchPaths: false, noBrowserGlobals: false })
|
|
4914
4927
|
};
|
|
4915
4928
|
const internalPerfObserve = {
|
|
@@ -5660,6 +5673,26 @@ const internalEncoding = {
|
|
|
5660
5673
|
return globalThis.TextEncoder;
|
|
5661
5674
|
}
|
|
5662
5675
|
};
|
|
5676
|
+
const hostProcess$1 = typeof process !== "undefined" && process !== null ? process : null;
|
|
5677
|
+
let loaded;
|
|
5678
|
+
function hostAmaro() {
|
|
5679
|
+
if (loaded !== void 0) return loaded;
|
|
5680
|
+
loaded = null;
|
|
5681
|
+
try {
|
|
5682
|
+
const moduleBuiltin = typeof (hostProcess$1 == null ? void 0 : hostProcess$1.getBuiltinModule) === "function" ? hostProcess$1.getBuiltinModule("module") : void 0;
|
|
5683
|
+
if (moduleBuiltin && typeof moduleBuiltin.createRequire === "function") {
|
|
5684
|
+
const amaro = moduleBuiltin.createRequire(import.meta.url)("amaro");
|
|
5685
|
+
if (typeof (amaro == null ? void 0 : amaro.transformSync) === "function") loaded = amaro;
|
|
5686
|
+
}
|
|
5687
|
+
} catch {
|
|
5688
|
+
}
|
|
5689
|
+
return loaded;
|
|
5690
|
+
}
|
|
5691
|
+
function internalAmaro() {
|
|
5692
|
+
const amaro = hostAmaro();
|
|
5693
|
+
if (amaro) return amaro;
|
|
5694
|
+
throw Object.assign(new Error("Node.js is not compiled with TypeScript support"), { code: "ERR_NO_TYPESCRIPT" });
|
|
5695
|
+
}
|
|
5663
5696
|
var __table$2;
|
|
5664
5697
|
function nodeLibInternal(name, require2, process2) {
|
|
5665
5698
|
if (require2 && name === "internal/webstreams/adapters") return () => createWebStreamsAdapters(require2);
|
|
@@ -5708,6 +5741,7 @@ function nodeLibInternal(name, require2, process2) {
|
|
|
5708
5741
|
"internal/process/warning": () => internalProcessWarning,
|
|
5709
5742
|
"internal/source_map/source_map_cache": () => internalSourceMapCache,
|
|
5710
5743
|
"internal/deps/undici/undici": () => internalUndici,
|
|
5744
|
+
"internal/deps/amaro/dist/index": () => internalAmaro(),
|
|
5711
5745
|
"internal/readline/interface": () => internalReadlineInterface,
|
|
5712
5746
|
"internal/worker/js_transferable": () => internalJsTransferable
|
|
5713
5747
|
});
|
|
@@ -6566,6 +6600,10 @@ function forgetRunPid(token) {
|
|
|
6566
6600
|
processRegistry.forget(token);
|
|
6567
6601
|
pidsOfRuns.delete(token);
|
|
6568
6602
|
}
|
|
6603
|
+
function tokenOfPid(pid) {
|
|
6604
|
+
for (const [token, numbers] of pidsOfRuns) if (numbers.pid === pid) return token;
|
|
6605
|
+
return null;
|
|
6606
|
+
}
|
|
6569
6607
|
function pidIsLive(pid) {
|
|
6570
6608
|
return processRegistry.lookup(pid) !== void 0;
|
|
6571
6609
|
}
|
|
@@ -11556,7 +11594,7 @@ const updatewindow = (strm, src, end, copy2) => {
|
|
|
11556
11594
|
}
|
|
11557
11595
|
return 0;
|
|
11558
11596
|
};
|
|
11559
|
-
const inflate = (strm,
|
|
11597
|
+
const inflate = (strm, flush2) => {
|
|
11560
11598
|
let state;
|
|
11561
11599
|
let input, output;
|
|
11562
11600
|
let next;
|
|
@@ -11894,7 +11932,7 @@ const inflate = (strm, flush) => {
|
|
|
11894
11932
|
strm.adler = state.check = 1;
|
|
11895
11933
|
state.mode = TYPE;
|
|
11896
11934
|
case TYPE:
|
|
11897
|
-
if (
|
|
11935
|
+
if (flush2 === Z_BLOCK$1 || flush2 === Z_TREES) {
|
|
11898
11936
|
break inf_leave;
|
|
11899
11937
|
}
|
|
11900
11938
|
case TYPEDO:
|
|
@@ -11922,7 +11960,7 @@ const inflate = (strm, flush) => {
|
|
|
11922
11960
|
case 1:
|
|
11923
11961
|
fixedtables(state);
|
|
11924
11962
|
state.mode = LEN_;
|
|
11925
|
-
if (
|
|
11963
|
+
if (flush2 === Z_TREES) {
|
|
11926
11964
|
hold2 >>>= 2;
|
|
11927
11965
|
bits -= 2;
|
|
11928
11966
|
break inf_leave;
|
|
@@ -11958,7 +11996,7 @@ const inflate = (strm, flush) => {
|
|
|
11958
11996
|
hold2 = 0;
|
|
11959
11997
|
bits = 0;
|
|
11960
11998
|
state.mode = COPY_;
|
|
11961
|
-
if (
|
|
11999
|
+
if (flush2 === Z_TREES) {
|
|
11962
12000
|
break inf_leave;
|
|
11963
12001
|
}
|
|
11964
12002
|
case COPY_:
|
|
@@ -12153,7 +12191,7 @@ const inflate = (strm, flush) => {
|
|
|
12153
12191
|
break;
|
|
12154
12192
|
}
|
|
12155
12193
|
state.mode = LEN_;
|
|
12156
|
-
if (
|
|
12194
|
+
if (flush2 === Z_TREES) {
|
|
12157
12195
|
break inf_leave;
|
|
12158
12196
|
}
|
|
12159
12197
|
case LEN_:
|
|
@@ -12443,7 +12481,7 @@ const inflate = (strm, flush) => {
|
|
|
12443
12481
|
strm.avail_in = have;
|
|
12444
12482
|
state.hold = hold2;
|
|
12445
12483
|
state.bits = bits;
|
|
12446
|
-
if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK ||
|
|
12484
|
+
if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush2 !== Z_FINISH$1)) {
|
|
12447
12485
|
if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) ;
|
|
12448
12486
|
}
|
|
12449
12487
|
_in -= strm.avail_in;
|
|
@@ -12456,7 +12494,7 @@ const inflate = (strm, flush) => {
|
|
|
12456
12494
|
state.flags ? crc32$1(state.check, output, _out, strm.next_out - _out) : adler32$1(state.check, output, _out, strm.next_out - _out);
|
|
12457
12495
|
}
|
|
12458
12496
|
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
|
12459
|
-
if ((_in === 0 && _out === 0 ||
|
|
12497
|
+
if ((_in === 0 && _out === 0 || flush2 === Z_FINISH$1) && ret === Z_OK$1) {
|
|
12460
12498
|
ret = Z_BUF_ERROR$1;
|
|
12461
12499
|
}
|
|
12462
12500
|
return ret;
|
|
@@ -13406,7 +13444,7 @@ const fill_window = (s) => {
|
|
|
13406
13444
|
}
|
|
13407
13445
|
} while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
|
|
13408
13446
|
};
|
|
13409
|
-
const deflate_stored = (s,
|
|
13447
|
+
const deflate_stored = (s, flush2) => {
|
|
13410
13448
|
let min_block = s.pending_buf_size - 5 > s.w_size ? s.w_size : s.pending_buf_size - 5;
|
|
13411
13449
|
let len2, left, have, last = 0;
|
|
13412
13450
|
let used = s.strm.avail_in;
|
|
@@ -13424,10 +13462,10 @@ const deflate_stored = (s, flush) => {
|
|
|
13424
13462
|
if (len2 > have) {
|
|
13425
13463
|
len2 = have;
|
|
13426
13464
|
}
|
|
13427
|
-
if (len2 < min_block && (len2 === 0 &&
|
|
13465
|
+
if (len2 < min_block && (len2 === 0 && flush2 !== Z_FINISH || flush2 === Z_NO_FLUSH || len2 !== left + s.strm.avail_in)) {
|
|
13428
13466
|
break;
|
|
13429
13467
|
}
|
|
13430
|
-
last =
|
|
13468
|
+
last = flush2 === Z_FINISH && len2 === left + s.strm.avail_in ? 1 : 0;
|
|
13431
13469
|
_tr_stored_block(s, 0, 0, last);
|
|
13432
13470
|
s.pending_buf[s.pending - 4] = len2;
|
|
13433
13471
|
s.pending_buf[s.pending - 3] = len2 >> 8;
|
|
@@ -13482,7 +13520,7 @@ const deflate_stored = (s, flush) => {
|
|
|
13482
13520
|
if (last) {
|
|
13483
13521
|
return BS_FINISH_DONE;
|
|
13484
13522
|
}
|
|
13485
|
-
if (
|
|
13523
|
+
if (flush2 !== Z_NO_FLUSH && flush2 !== Z_FINISH && s.strm.avail_in === 0 && s.strstart === s.block_start) {
|
|
13486
13524
|
return BS_BLOCK_DONE;
|
|
13487
13525
|
}
|
|
13488
13526
|
have = s.window_size - s.strstart;
|
|
@@ -13513,22 +13551,22 @@ const deflate_stored = (s, flush) => {
|
|
|
13513
13551
|
have = s.pending_buf_size - have > 65535 ? 65535 : s.pending_buf_size - have;
|
|
13514
13552
|
min_block = have > s.w_size ? s.w_size : have;
|
|
13515
13553
|
left = s.strstart - s.block_start;
|
|
13516
|
-
if (left >= min_block || (left ||
|
|
13554
|
+
if (left >= min_block || (left || flush2 === Z_FINISH) && flush2 !== Z_NO_FLUSH && s.strm.avail_in === 0 && left <= have) {
|
|
13517
13555
|
len2 = left > have ? have : left;
|
|
13518
|
-
last =
|
|
13556
|
+
last = flush2 === Z_FINISH && s.strm.avail_in === 0 && len2 === left ? 1 : 0;
|
|
13519
13557
|
_tr_stored_block(s, s.block_start, len2, last);
|
|
13520
13558
|
s.block_start += len2;
|
|
13521
13559
|
flush_pending(s.strm);
|
|
13522
13560
|
}
|
|
13523
13561
|
return last ? BS_FINISH_STARTED : BS_NEED_MORE;
|
|
13524
13562
|
};
|
|
13525
|
-
const deflate_fast = (s,
|
|
13563
|
+
const deflate_fast = (s, flush2) => {
|
|
13526
13564
|
let hash_head;
|
|
13527
13565
|
let bflush;
|
|
13528
13566
|
for (; ; ) {
|
|
13529
13567
|
if (s.lookahead < MIN_LOOKAHEAD) {
|
|
13530
13568
|
fill_window(s);
|
|
13531
|
-
if (s.lookahead < MIN_LOOKAHEAD &&
|
|
13569
|
+
if (s.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH) {
|
|
13532
13570
|
return BS_NEED_MORE;
|
|
13533
13571
|
}
|
|
13534
13572
|
if (s.lookahead === 0) {
|
|
@@ -13575,7 +13613,7 @@ const deflate_fast = (s, flush) => {
|
|
|
13575
13613
|
}
|
|
13576
13614
|
}
|
|
13577
13615
|
s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
|
|
13578
|
-
if (
|
|
13616
|
+
if (flush2 === Z_FINISH) {
|
|
13579
13617
|
flush_block_only(s, true);
|
|
13580
13618
|
if (s.strm.avail_out === 0) {
|
|
13581
13619
|
return BS_FINISH_STARTED;
|
|
@@ -13590,14 +13628,14 @@ const deflate_fast = (s, flush) => {
|
|
|
13590
13628
|
}
|
|
13591
13629
|
return BS_BLOCK_DONE;
|
|
13592
13630
|
};
|
|
13593
|
-
const deflate_slow = (s,
|
|
13631
|
+
const deflate_slow = (s, flush2) => {
|
|
13594
13632
|
let hash_head;
|
|
13595
13633
|
let bflush;
|
|
13596
13634
|
let max_insert;
|
|
13597
13635
|
for (; ; ) {
|
|
13598
13636
|
if (s.lookahead < MIN_LOOKAHEAD) {
|
|
13599
13637
|
fill_window(s);
|
|
13600
|
-
if (s.lookahead < MIN_LOOKAHEAD &&
|
|
13638
|
+
if (s.lookahead < MIN_LOOKAHEAD && flush2 === Z_NO_FLUSH) {
|
|
13601
13639
|
return BS_NEED_MORE;
|
|
13602
13640
|
}
|
|
13603
13641
|
if (s.lookahead === 0) {
|
|
@@ -13661,7 +13699,7 @@ const deflate_slow = (s, flush) => {
|
|
|
13661
13699
|
s.match_available = 0;
|
|
13662
13700
|
}
|
|
13663
13701
|
s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
|
|
13664
|
-
if (
|
|
13702
|
+
if (flush2 === Z_FINISH) {
|
|
13665
13703
|
flush_block_only(s, true);
|
|
13666
13704
|
if (s.strm.avail_out === 0) {
|
|
13667
13705
|
return BS_FINISH_STARTED;
|
|
@@ -13676,7 +13714,7 @@ const deflate_slow = (s, flush) => {
|
|
|
13676
13714
|
}
|
|
13677
13715
|
return BS_BLOCK_DONE;
|
|
13678
13716
|
};
|
|
13679
|
-
const deflate_rle = (s,
|
|
13717
|
+
const deflate_rle = (s, flush2) => {
|
|
13680
13718
|
let bflush;
|
|
13681
13719
|
let prev;
|
|
13682
13720
|
let scan, strend;
|
|
@@ -13684,7 +13722,7 @@ const deflate_rle = (s, flush) => {
|
|
|
13684
13722
|
for (; ; ) {
|
|
13685
13723
|
if (s.lookahead <= MAX_MATCH) {
|
|
13686
13724
|
fill_window(s);
|
|
13687
|
-
if (s.lookahead <= MAX_MATCH &&
|
|
13725
|
+
if (s.lookahead <= MAX_MATCH && flush2 === Z_NO_FLUSH) {
|
|
13688
13726
|
return BS_NEED_MORE;
|
|
13689
13727
|
}
|
|
13690
13728
|
if (s.lookahead === 0) {
|
|
@@ -13723,7 +13761,7 @@ const deflate_rle = (s, flush) => {
|
|
|
13723
13761
|
}
|
|
13724
13762
|
}
|
|
13725
13763
|
s.insert = 0;
|
|
13726
|
-
if (
|
|
13764
|
+
if (flush2 === Z_FINISH) {
|
|
13727
13765
|
flush_block_only(s, true);
|
|
13728
13766
|
if (s.strm.avail_out === 0) {
|
|
13729
13767
|
return BS_FINISH_STARTED;
|
|
@@ -13738,13 +13776,13 @@ const deflate_rle = (s, flush) => {
|
|
|
13738
13776
|
}
|
|
13739
13777
|
return BS_BLOCK_DONE;
|
|
13740
13778
|
};
|
|
13741
|
-
const deflate_huff = (s,
|
|
13779
|
+
const deflate_huff = (s, flush2) => {
|
|
13742
13780
|
let bflush;
|
|
13743
13781
|
for (; ; ) {
|
|
13744
13782
|
if (s.lookahead === 0) {
|
|
13745
13783
|
fill_window(s);
|
|
13746
13784
|
if (s.lookahead === 0) {
|
|
13747
|
-
if (
|
|
13785
|
+
if (flush2 === Z_NO_FLUSH) {
|
|
13748
13786
|
return BS_NEED_MORE;
|
|
13749
13787
|
}
|
|
13750
13788
|
break;
|
|
@@ -13762,7 +13800,7 @@ const deflate_huff = (s, flush) => {
|
|
|
13762
13800
|
}
|
|
13763
13801
|
}
|
|
13764
13802
|
s.insert = 0;
|
|
13765
|
-
if (
|
|
13803
|
+
if (flush2 === Z_FINISH) {
|
|
13766
13804
|
flush_block_only(s, true);
|
|
13767
13805
|
if (s.strm.avail_out === 0) {
|
|
13768
13806
|
return BS_FINISH_STARTED;
|
|
@@ -13985,23 +14023,23 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
|
13985
14023
|
const deflateInit = (strm, level) => {
|
|
13986
14024
|
return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
|
|
13987
14025
|
};
|
|
13988
|
-
const deflate = (strm,
|
|
13989
|
-
if (deflateStateCheck(strm) ||
|
|
14026
|
+
const deflate = (strm, flush2) => {
|
|
14027
|
+
if (deflateStateCheck(strm) || flush2 > Z_BLOCK || flush2 < 0) {
|
|
13990
14028
|
return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;
|
|
13991
14029
|
}
|
|
13992
14030
|
const s = strm.state;
|
|
13993
|
-
if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE &&
|
|
14031
|
+
if (!strm.output || strm.avail_in !== 0 && !strm.input || s.status === FINISH_STATE && flush2 !== Z_FINISH) {
|
|
13994
14032
|
return err(strm, strm.avail_out === 0 ? Z_BUF_ERROR : Z_STREAM_ERROR);
|
|
13995
14033
|
}
|
|
13996
14034
|
const old_flush = s.last_flush;
|
|
13997
|
-
s.last_flush =
|
|
14035
|
+
s.last_flush = flush2;
|
|
13998
14036
|
if (s.pending !== 0) {
|
|
13999
14037
|
flush_pending(strm);
|
|
14000
14038
|
if (strm.avail_out === 0) {
|
|
14001
14039
|
s.last_flush = -1;
|
|
14002
14040
|
return Z_OK;
|
|
14003
14041
|
}
|
|
14004
|
-
} else if (strm.avail_in === 0 && rank(
|
|
14042
|
+
} else if (strm.avail_in === 0 && rank(flush2) <= rank(old_flush) && flush2 !== Z_FINISH) {
|
|
14005
14043
|
return err(strm, Z_BUF_ERROR);
|
|
14006
14044
|
}
|
|
14007
14045
|
if (s.status === FINISH_STATE && strm.avail_in !== 0) {
|
|
@@ -14190,8 +14228,8 @@ const deflate = (strm, flush) => {
|
|
|
14190
14228
|
return Z_OK;
|
|
14191
14229
|
}
|
|
14192
14230
|
}
|
|
14193
|
-
if (strm.avail_in !== 0 || s.lookahead !== 0 ||
|
|
14194
|
-
let bstate = s.level === 0 ? deflate_stored(s,
|
|
14231
|
+
if (strm.avail_in !== 0 || s.lookahead !== 0 || flush2 !== Z_NO_FLUSH && s.status !== FINISH_STATE) {
|
|
14232
|
+
let bstate = s.level === 0 ? deflate_stored(s, flush2) : s.strategy === Z_HUFFMAN_ONLY ? deflate_huff(s, flush2) : s.strategy === Z_RLE ? deflate_rle(s, flush2) : configuration_table[s.level].func(s, flush2);
|
|
14195
14233
|
if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
|
|
14196
14234
|
s.status = FINISH_STATE;
|
|
14197
14235
|
}
|
|
@@ -14202,11 +14240,11 @@ const deflate = (strm, flush) => {
|
|
|
14202
14240
|
return Z_OK;
|
|
14203
14241
|
}
|
|
14204
14242
|
if (bstate === BS_BLOCK_DONE) {
|
|
14205
|
-
if (
|
|
14243
|
+
if (flush2 === Z_PARTIAL_FLUSH) {
|
|
14206
14244
|
_tr_align(s);
|
|
14207
|
-
} else if (
|
|
14245
|
+
} else if (flush2 !== Z_BLOCK) {
|
|
14208
14246
|
_tr_stored_block(s, 0, 0, false);
|
|
14209
|
-
if (
|
|
14247
|
+
if (flush2 === Z_FULL_FLUSH) {
|
|
14210
14248
|
zero(s.head);
|
|
14211
14249
|
if (s.lookahead === 0) {
|
|
14212
14250
|
s.strstart = 0;
|
|
@@ -14222,7 +14260,7 @@ const deflate = (strm, flush) => {
|
|
|
14222
14260
|
}
|
|
14223
14261
|
}
|
|
14224
14262
|
}
|
|
14225
|
-
if (
|
|
14263
|
+
if (flush2 !== Z_FINISH) {
|
|
14226
14264
|
return Z_OK;
|
|
14227
14265
|
}
|
|
14228
14266
|
if (s.wrap <= 0) {
|
|
@@ -16674,10 +16712,10 @@ prefix.kCopyRangeLut = [
|
|
|
16674
16712
|
8,
|
|
16675
16713
|
16
|
|
16676
16714
|
];
|
|
16677
|
-
var transform$
|
|
16715
|
+
var transform$2 = {};
|
|
16678
16716
|
var hasRequiredTransform;
|
|
16679
16717
|
function requireTransform() {
|
|
16680
|
-
if (hasRequiredTransform) return transform$
|
|
16718
|
+
if (hasRequiredTransform) return transform$2;
|
|
16681
16719
|
hasRequiredTransform = 1;
|
|
16682
16720
|
var BrotliDictionary = requireDictionary();
|
|
16683
16721
|
var kIdentity = 0;
|
|
@@ -16832,8 +16870,8 @@ function requireTransform() {
|
|
|
16832
16870
|
new Transform(" ", kUppercaseAll, "='"),
|
|
16833
16871
|
new Transform(" ", kUppercaseFirst, "='")
|
|
16834
16872
|
];
|
|
16835
|
-
transform$
|
|
16836
|
-
transform$
|
|
16873
|
+
transform$2.kTransforms = kTransforms;
|
|
16874
|
+
transform$2.kNumTransforms = kTransforms.length;
|
|
16837
16875
|
function ToUpperCase(p, i2) {
|
|
16838
16876
|
if (p[i2] < 192) {
|
|
16839
16877
|
if (p[i2] >= 97 && p[i2] <= 122) {
|
|
@@ -16848,7 +16886,7 @@ function requireTransform() {
|
|
|
16848
16886
|
p[i2 + 2] ^= 5;
|
|
16849
16887
|
return 3;
|
|
16850
16888
|
}
|
|
16851
|
-
transform$
|
|
16889
|
+
transform$2.transformDictionaryWord = function(dst, idx, word, len2, transform2) {
|
|
16852
16890
|
var prefix2 = kTransforms[transform2].prefix;
|
|
16853
16891
|
var suffix = kTransforms[transform2].suffix;
|
|
16854
16892
|
var t = kTransforms[transform2].transform;
|
|
@@ -16887,7 +16925,7 @@ function requireTransform() {
|
|
|
16887
16925
|
}
|
|
16888
16926
|
return idx - start_idx;
|
|
16889
16927
|
};
|
|
16890
|
-
return transform$
|
|
16928
|
+
return transform$2;
|
|
16891
16929
|
}
|
|
16892
16930
|
var hasRequiredDecode;
|
|
16893
16931
|
function requireDecode() {
|
|
@@ -17775,20 +17813,20 @@ class Zlib {
|
|
|
17775
17813
|
__privateSet(this, _dictionary, dictionary2);
|
|
17776
17814
|
__privateMethod(this, _Zlib_instances, start_fn).call(this);
|
|
17777
17815
|
}
|
|
17778
|
-
write(
|
|
17816
|
+
write(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
17779
17817
|
var _a2;
|
|
17780
17818
|
const tick = ((_a2 = globalThis.process) == null ? void 0 : _a2.nextTick) ?? ((fn) => {
|
|
17781
17819
|
queueMicrotask(fn);
|
|
17782
17820
|
});
|
|
17783
17821
|
tick(() => {
|
|
17784
17822
|
var _a3;
|
|
17785
|
-
__privateMethod(this, _Zlib_instances, run_fn).call(this,
|
|
17823
|
+
__privateMethod(this, _Zlib_instances, run_fn).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
|
|
17786
17824
|
(_a3 = __privateGet(this, _callback)) == null ? void 0 : _a3.call(this);
|
|
17787
17825
|
});
|
|
17788
17826
|
return this;
|
|
17789
17827
|
}
|
|
17790
|
-
writeSync(
|
|
17791
|
-
__privateMethod(this, _Zlib_instances, run_fn).call(this,
|
|
17828
|
+
writeSync(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
17829
|
+
__privateMethod(this, _Zlib_instances, run_fn).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
|
|
17792
17830
|
return this;
|
|
17793
17831
|
}
|
|
17794
17832
|
/**
|
|
@@ -17876,7 +17914,7 @@ report_fn = function(strm) {
|
|
|
17876
17914
|
state[0] = strm.avail_out;
|
|
17877
17915
|
state[1] = strm.avail_in;
|
|
17878
17916
|
};
|
|
17879
|
-
run_fn = function(
|
|
17917
|
+
run_fn = function(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
17880
17918
|
var _a2;
|
|
17881
17919
|
const strm = __privateGet(this, _strm);
|
|
17882
17920
|
if (!strm) {
|
|
@@ -17889,11 +17927,11 @@ run_fn = function(flush, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
|
17889
17927
|
strm.output = outBuf;
|
|
17890
17928
|
strm.next_out = outOff;
|
|
17891
17929
|
strm.avail_out = outLen;
|
|
17892
|
-
const status = __privateGet(this, _Zlib_instances, inflating_get) ? inflateModule.inflate(strm,
|
|
17930
|
+
const status = __privateGet(this, _Zlib_instances, inflating_get) ? inflateModule.inflate(strm, flush2) : deflateModule.deflate(strm, flush2);
|
|
17893
17931
|
if (status === zlibConstants.Z_NEED_DICT && __privateGet(this, _dictionary)) {
|
|
17894
17932
|
const dictStatus = inflateModule.inflateSetDictionary(strm, __privateGet(this, _dictionary));
|
|
17895
17933
|
if (dictStatus === zlibConstants.Z_OK) {
|
|
17896
|
-
const again = inflateModule.inflate(strm,
|
|
17934
|
+
const again = inflateModule.inflate(strm, flush2);
|
|
17897
17935
|
if (again !== zlibConstants.Z_OK && again !== zlibConstants.Z_STREAM_END && again !== zlibConstants.Z_BUF_ERROR) {
|
|
17898
17936
|
__privateMethod(this, _Zlib_instances, fail_fn).call(this, again, strm);
|
|
17899
17937
|
return;
|
|
@@ -17948,20 +17986,20 @@ class BrotliDecoderHandle {
|
|
|
17948
17986
|
__privateSet(this, _callback2, processCallback);
|
|
17949
17987
|
return true;
|
|
17950
17988
|
}
|
|
17951
|
-
write(
|
|
17989
|
+
write(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
17952
17990
|
var _a2;
|
|
17953
17991
|
const tick = ((_a2 = globalThis.process) == null ? void 0 : _a2.nextTick) ?? ((fn) => {
|
|
17954
17992
|
queueMicrotask(fn);
|
|
17955
17993
|
});
|
|
17956
17994
|
tick(() => {
|
|
17957
17995
|
var _a3;
|
|
17958
|
-
__privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this,
|
|
17996
|
+
__privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
|
|
17959
17997
|
(_a3 = __privateGet(this, _callback2)) == null ? void 0 : _a3.call(this);
|
|
17960
17998
|
});
|
|
17961
17999
|
return this;
|
|
17962
18000
|
}
|
|
17963
|
-
writeSync(
|
|
17964
|
-
__privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this,
|
|
18001
|
+
writeSync(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
18002
|
+
__privateMethod(this, _BrotliDecoderHandle_instances, run_fn2).call(this, flush2, inBuf, inOff, inLen, outBuf, outOff, outLen);
|
|
17965
18003
|
return this;
|
|
17966
18004
|
}
|
|
17967
18005
|
params() {
|
|
@@ -17985,10 +18023,10 @@ _input = new WeakMap();
|
|
|
17985
18023
|
_output = new WeakMap();
|
|
17986
18024
|
_outputAt = new WeakMap();
|
|
17987
18025
|
_BrotliDecoderHandle_instances = new WeakSet();
|
|
17988
|
-
run_fn2 = function(
|
|
18026
|
+
run_fn2 = function(flush2, inBuf, inOff, inLen, outBuf, outOff, outLen) {
|
|
17989
18027
|
var _a2;
|
|
17990
18028
|
if (inBuf && inLen > 0) __privateGet(this, _input).push(inBuf.slice(inOff, inOff + inLen));
|
|
17991
|
-
if (
|
|
18029
|
+
if (flush2 === BROTLI_OPERATION_FINISH && __privateGet(this, _output) === null) {
|
|
17992
18030
|
const total = __privateGet(this, _input).reduce((sum, part) => sum + part.byteLength, 0);
|
|
17993
18031
|
const whole = new Uint8Array(total);
|
|
17994
18032
|
let at2 = 0;
|
|
@@ -19072,11 +19110,11 @@ const isWindows = false;
|
|
|
19072
19110
|
const isMacOS = false;
|
|
19073
19111
|
function getLazy(fn) {
|
|
19074
19112
|
let value;
|
|
19075
|
-
let
|
|
19113
|
+
let loaded2 = false;
|
|
19076
19114
|
return () => {
|
|
19077
|
-
if (!
|
|
19115
|
+
if (!loaded2) {
|
|
19078
19116
|
value = fn();
|
|
19079
|
-
|
|
19117
|
+
loaded2 = true;
|
|
19080
19118
|
}
|
|
19081
19119
|
return value;
|
|
19082
19120
|
};
|
|
@@ -30173,7 +30211,7 @@ function createTimersModule(owned) {
|
|
|
30173
30211
|
}
|
|
30174
30212
|
const NODE_LTS_VERSION = "22.12.0";
|
|
30175
30213
|
function nodeVersions(node = NODE_LTS_VERSION) {
|
|
30176
|
-
return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15" };
|
|
30214
|
+
return { node, v8: "11.3.244.8", uv: "1.44.2", webcontainer: "1", openssl: "3.0.15", amaro: "1.1.0" };
|
|
30177
30215
|
}
|
|
30178
30216
|
var StdinClasses;
|
|
30179
30217
|
function processStdinClass(ReadableClass) {
|
|
@@ -32885,6 +32923,418 @@ function __nodeResolverFor(fs, profile, extensions) {
|
|
|
32885
32923
|
byProfile.set(key, resolver);
|
|
32886
32924
|
return resolver;
|
|
32887
32925
|
}
|
|
32926
|
+
function unstreamedOutput(total, streamed) {
|
|
32927
|
+
let rest = total;
|
|
32928
|
+
let cursor = 0;
|
|
32929
|
+
for (const piece of streamed) {
|
|
32930
|
+
if (!piece) continue;
|
|
32931
|
+
const at2 = rest.indexOf(piece, cursor);
|
|
32932
|
+
if (at2 < 0) continue;
|
|
32933
|
+
rest = rest.slice(0, at2) + rest.slice(at2 + piece.length);
|
|
32934
|
+
cursor = at2;
|
|
32935
|
+
}
|
|
32936
|
+
return rest;
|
|
32937
|
+
}
|
|
32938
|
+
const LAST_JOB_VAR = "__TABNODE_LAST_JOB_PID";
|
|
32939
|
+
const SHELL_VAR = "__TABNODE_SHELL";
|
|
32940
|
+
const BG_COMMAND = "__tabnode_bg";
|
|
32941
|
+
const WAIT_COMMAND = "__tabnode_wait";
|
|
32942
|
+
const JOB_PLACEHOLDER = "__tabnode_job";
|
|
32943
|
+
const PENDING_LIMIT = 1 << 20;
|
|
32944
|
+
const IGNORED_BY_DEFAULT = /* @__PURE__ */ new Set(["SIGCHLD", "SIGCONT", "SIGURG", "SIGWINCH"]);
|
|
32945
|
+
const shells$1 = /* @__PURE__ */ new Map();
|
|
32946
|
+
const handoff = /* @__PURE__ */ new Map();
|
|
32947
|
+
let nextShell = 1;
|
|
32948
|
+
let nextJob = 1;
|
|
32949
|
+
function isNode(value) {
|
|
32950
|
+
return typeof value === "object" && value !== null;
|
|
32951
|
+
}
|
|
32952
|
+
function literalWord(value) {
|
|
32953
|
+
return { type: "Word", parts: [{ type: "Literal", value }] };
|
|
32954
|
+
}
|
|
32955
|
+
function wordLiteral(word) {
|
|
32956
|
+
if (!isNode(word) || !Array.isArray(word.parts) || word.parts.length !== 1) return null;
|
|
32957
|
+
const part = word.parts[0];
|
|
32958
|
+
return isNode(part) && part.type === "Literal" && typeof part.value === "string" ? part.value : null;
|
|
32959
|
+
}
|
|
32960
|
+
function definesFunction(statement) {
|
|
32961
|
+
const pipelines = statement.pipelines;
|
|
32962
|
+
return Array.isArray(pipelines) && pipelines.some((pipeline) => isNode(pipeline) && Array.isArray(pipeline.commands) && pipeline.commands.some((command) => isNode(command) && command.type === "FunctionDef"));
|
|
32963
|
+
}
|
|
32964
|
+
function functionDefinitions(node, found = []) {
|
|
32965
|
+
if (Array.isArray(node)) {
|
|
32966
|
+
for (const child of node) functionDefinitions(child, found);
|
|
32967
|
+
return found;
|
|
32968
|
+
}
|
|
32969
|
+
if (!isNode(node)) return found;
|
|
32970
|
+
if (node.type === "Statement" && node.background === true) return found;
|
|
32971
|
+
if (node.type === "Statement" && definesFunction(node)) found.push(node);
|
|
32972
|
+
for (const key of Object.keys(node)) functionDefinitions(node[key], found);
|
|
32973
|
+
return found;
|
|
32974
|
+
}
|
|
32975
|
+
function rewrite(node, functions) {
|
|
32976
|
+
if (Array.isArray(node)) {
|
|
32977
|
+
for (let index2 = 0; index2 < node.length; index2 += 1) {
|
|
32978
|
+
const child = node[index2];
|
|
32979
|
+
if (isNode(child) && child.type === "Statement" && child.background === true) {
|
|
32980
|
+
node[index2] = backgroundCall(child, functions);
|
|
32981
|
+
} else rewrite(child, functions);
|
|
32982
|
+
}
|
|
32983
|
+
return;
|
|
32984
|
+
}
|
|
32985
|
+
if (!isNode(node)) return;
|
|
32986
|
+
if (node.type === "ParameterExpansion" && node.parameter === "!") node.parameter = LAST_JOB_VAR;
|
|
32987
|
+
if (node.type === "SimpleCommand" && wordLiteral(node.name) === "wait") node.name = literalWord(WAIT_COMMAND);
|
|
32988
|
+
for (const key of Object.keys(node)) {
|
|
32989
|
+
const child = node[key];
|
|
32990
|
+
if (isNode(child) && child.type === "Statement" && child.background === true) node[key] = backgroundCall(child, functions);
|
|
32991
|
+
else rewrite(child, functions);
|
|
32992
|
+
}
|
|
32993
|
+
}
|
|
32994
|
+
function backgroundCall(statement, functions) {
|
|
32995
|
+
const job = JSON.stringify({ ...statement, background: false });
|
|
32996
|
+
return {
|
|
32997
|
+
type: "Statement",
|
|
32998
|
+
pipelines: [{
|
|
32999
|
+
type: "Pipeline",
|
|
33000
|
+
commands: [{
|
|
33001
|
+
type: "SimpleCommand",
|
|
33002
|
+
name: literalWord(BG_COMMAND),
|
|
33003
|
+
args: [{ type: "Word", parts: [{ type: "SingleQuoted", value: job }] }, { type: "Word", parts: [{ type: "SingleQuoted", value: functions }] }],
|
|
33004
|
+
assignments: [],
|
|
33005
|
+
redirections: []
|
|
33006
|
+
}],
|
|
33007
|
+
negated: false,
|
|
33008
|
+
timed: false,
|
|
33009
|
+
timePosix: false
|
|
33010
|
+
}],
|
|
33011
|
+
operators: [],
|
|
33012
|
+
background: false,
|
|
33013
|
+
...typeof statement.sourceText === "string" ? { sourceText: statement.sourceText } : {}
|
|
33014
|
+
};
|
|
33015
|
+
}
|
|
33016
|
+
function transform$1({ ast }) {
|
|
33017
|
+
let script = ast;
|
|
33018
|
+
const statements = Array.isArray(ast.statements) ? ast.statements : [];
|
|
33019
|
+
if (statements.length === 1 && isNode(statements[0])) {
|
|
33020
|
+
const pipelines = statements[0].pipelines;
|
|
33021
|
+
const command = Array.isArray(pipelines) && isNode(pipelines[0]) && Array.isArray(pipelines[0].commands) ? pipelines[0].commands[0] : void 0;
|
|
33022
|
+
if (isNode(command) && command.type === "SimpleCommand" && wordLiteral(command.name) === ":" && Array.isArray(command.args) && command.args.length === 2 && wordLiteral(command.args[0]) === JOB_PLACEHOLDER) {
|
|
33023
|
+
const token = wordLiteral(command.args[1]);
|
|
33024
|
+
const own = token === null ? void 0 : handoff.get(token);
|
|
33025
|
+
if (own && token !== null) {
|
|
33026
|
+
handoff.delete(token);
|
|
33027
|
+
script = own;
|
|
33028
|
+
}
|
|
33029
|
+
}
|
|
33030
|
+
}
|
|
33031
|
+
if (!Array.isArray(script.statements) || !JSON.stringify(script).match(/"background":true|"parameter":"!"|"value":"wait"/u)) return { ast: script };
|
|
33032
|
+
const functions = JSON.stringify(functionDefinitions(script.statements));
|
|
33033
|
+
rewrite(script.statements, functions);
|
|
33034
|
+
return { ast: script };
|
|
33035
|
+
}
|
|
33036
|
+
function shellOf$1(ctx) {
|
|
33037
|
+
let id = ctx.env.get(SHELL_VAR);
|
|
33038
|
+
if (!id) {
|
|
33039
|
+
id = `shell-${nextShell++}`;
|
|
33040
|
+
ctx.env.set(SHELL_VAR, id);
|
|
33041
|
+
}
|
|
33042
|
+
let shell = shells$1.get(id);
|
|
33043
|
+
if (!shell) {
|
|
33044
|
+
shell = { jobs: /* @__PURE__ */ new Map(), order: [], pendingOut: "", pendingErr: "" };
|
|
33045
|
+
shells$1.set(id, shell);
|
|
33046
|
+
}
|
|
33047
|
+
return { id, shell };
|
|
33048
|
+
}
|
|
33049
|
+
function signalNumber(name) {
|
|
33050
|
+
return __substrateSignals[name] ?? 15;
|
|
33051
|
+
}
|
|
33052
|
+
function signalName(spec) {
|
|
33053
|
+
const bare = spec.startsWith("-") ? spec.slice(1) : spec;
|
|
33054
|
+
if (/^\d+$/u.test(bare)) {
|
|
33055
|
+
const number = Number(bare);
|
|
33056
|
+
if (number === 0) return "0";
|
|
33057
|
+
return __substrateSignalNames[number > 128 ? number - 128 : number] ?? null;
|
|
33058
|
+
}
|
|
33059
|
+
const upper = bare.toUpperCase();
|
|
33060
|
+
const name = upper.startsWith("SIG") ? upper : `SIG${upper}`;
|
|
33061
|
+
return __substrateSignals[name] !== void 0 ? name : null;
|
|
33062
|
+
}
|
|
33063
|
+
function startJob(host2, ctx, shell, script, sourceText) {
|
|
33064
|
+
var _a2;
|
|
33065
|
+
const token = `job-${nextJob++}`;
|
|
33066
|
+
const parent = host2.runTokenOf(ctx);
|
|
33067
|
+
const parentPid = (_a2 = runPid(parent)) == null ? void 0 : _a2.pid;
|
|
33068
|
+
const pid = mintPid();
|
|
33069
|
+
setRunPid(token, pid, parentPid !== void 0 && pidIsLive(parentPid) ? parentPid : 0, { argv: ["sh", "-c", sourceText], cwd: ctx.cwd });
|
|
33070
|
+
const controller = new AbortController();
|
|
33071
|
+
let streamedOut = [];
|
|
33072
|
+
let streamedErr = [];
|
|
33073
|
+
const live = () => parent === null ? void 0 : host2.runStreamsFor(parent);
|
|
33074
|
+
host2.registerRunStreams(token, {
|
|
33075
|
+
onStdout: (data2) => {
|
|
33076
|
+
var _a3, _b2;
|
|
33077
|
+
streamedOut.push(data2);
|
|
33078
|
+
(_b2 = (_a3 = live()) == null ? void 0 : _a3.onStdout) == null ? void 0 : _b2.call(_a3, data2);
|
|
33079
|
+
},
|
|
33080
|
+
onStderr: (data2) => {
|
|
33081
|
+
var _a3, _b2;
|
|
33082
|
+
streamedErr.push(data2);
|
|
33083
|
+
(_b2 = (_a3 = live()) == null ? void 0 : _a3.onStderr) == null ? void 0 : _b2.call(_a3, data2);
|
|
33084
|
+
},
|
|
33085
|
+
signal: controller.signal,
|
|
33086
|
+
held: false
|
|
33087
|
+
});
|
|
33088
|
+
let settle = () => {
|
|
33089
|
+
};
|
|
33090
|
+
const job = {
|
|
33091
|
+
pid,
|
|
33092
|
+
token,
|
|
33093
|
+
status: null,
|
|
33094
|
+
done: new Promise((resolve2) => {
|
|
33095
|
+
settle = resolve2;
|
|
33096
|
+
}),
|
|
33097
|
+
kill(signal) {
|
|
33098
|
+
if (job.status !== null) return false;
|
|
33099
|
+
if (__signalOwnedProcess(token, signal) || signalPid(pid, signal)) return true;
|
|
33100
|
+
if (IGNORED_BY_DEFAULT.has(signal)) return true;
|
|
33101
|
+
controller.abort(signal);
|
|
33102
|
+
__releaseOwnedServers(token, false);
|
|
33103
|
+
__releaseOwnedHandles(token);
|
|
33104
|
+
__stopOwnedProcess(token);
|
|
33105
|
+
end(128 + signalNumber(signal));
|
|
33106
|
+
return true;
|
|
33107
|
+
}
|
|
33108
|
+
};
|
|
33109
|
+
const end = (status) => {
|
|
33110
|
+
if (job.status !== null) return;
|
|
33111
|
+
job.status = status;
|
|
33112
|
+
host2.releaseRunStreams(token);
|
|
33113
|
+
forgetRunPid(token);
|
|
33114
|
+
__substrateChildren.delete(pid);
|
|
33115
|
+
settle(status);
|
|
33116
|
+
};
|
|
33117
|
+
const hold2 = (text, key) => {
|
|
33118
|
+
if (!text) return;
|
|
33119
|
+
const room = PENDING_LIMIT - shell[key].length;
|
|
33120
|
+
if (room > 0) shell[key] += text.slice(0, room);
|
|
33121
|
+
};
|
|
33122
|
+
const env = Object.fromEntries(ctx.env);
|
|
33123
|
+
delete env[SHELL_VAR];
|
|
33124
|
+
env[PROCESS_TOKEN_ENV] = token;
|
|
33125
|
+
handoff.set(token, script);
|
|
33126
|
+
__substrateChildren.set(pid, {
|
|
33127
|
+
get exitCode() {
|
|
33128
|
+
return job.status;
|
|
33129
|
+
},
|
|
33130
|
+
signalCode: null,
|
|
33131
|
+
kill: (signal = "SIGTERM") => job.kill(signal)
|
|
33132
|
+
});
|
|
33133
|
+
const run = ctx.exec ? enterRun(token, () => ctx.exec(`: ${JOB_PLACEHOLDER} ${token}`, { env, cwd: ctx.cwd, replaceEnv: true, signal: controller.signal })) : Promise.resolve({ stdout: "", stderr: "bash: background jobs need a shell that can run a script\n", exitCode: 1 });
|
|
33134
|
+
void Promise.resolve(run).then(
|
|
33135
|
+
(result) => {
|
|
33136
|
+
var _a3, _b2, _c2, _d2;
|
|
33137
|
+
handoff.delete(token);
|
|
33138
|
+
const stdout = result.stdout ?? "";
|
|
33139
|
+
const stderr = result.stderr ?? "";
|
|
33140
|
+
const restOut = unstreamedOutput(stdout, streamedOut);
|
|
33141
|
+
const restErr = unstreamedOutput(stderr, streamedErr);
|
|
33142
|
+
if (restOut) (_b2 = (_a3 = live()) == null ? void 0 : _a3.onStdout) == null ? void 0 : _b2.call(_a3, restOut);
|
|
33143
|
+
if (restErr) (_d2 = (_c2 = live()) == null ? void 0 : _c2.onStderr) == null ? void 0 : _d2.call(_c2, restErr);
|
|
33144
|
+
hold2(stdout, "pendingOut");
|
|
33145
|
+
hold2(stderr, "pendingErr");
|
|
33146
|
+
streamedOut = [];
|
|
33147
|
+
streamedErr = [];
|
|
33148
|
+
end(result.exitCode ?? 0);
|
|
33149
|
+
},
|
|
33150
|
+
(error) => {
|
|
33151
|
+
var _a3, _b2;
|
|
33152
|
+
handoff.delete(token);
|
|
33153
|
+
const text = `${error instanceof Error ? error.message : String(error)}
|
|
33154
|
+
`;
|
|
33155
|
+
(_b2 = (_a3 = live()) == null ? void 0 : _a3.onStderr) == null ? void 0 : _b2.call(_a3, text);
|
|
33156
|
+
hold2(text, "pendingErr");
|
|
33157
|
+
end(1);
|
|
33158
|
+
}
|
|
33159
|
+
);
|
|
33160
|
+
return job;
|
|
33161
|
+
}
|
|
33162
|
+
function flush(shell) {
|
|
33163
|
+
const taken = { stdout: shell.pendingOut, stderr: shell.pendingErr };
|
|
33164
|
+
shell.pendingOut = "";
|
|
33165
|
+
shell.pendingErr = "";
|
|
33166
|
+
return taken;
|
|
33167
|
+
}
|
|
33168
|
+
function installShellJobs(bash, host2) {
|
|
33169
|
+
bash.registerTransformPlugin({ name: "tabnode-background-jobs", transform: transform$1 });
|
|
33170
|
+
bash.registerCommand(defineCommand(BG_COMMAND, async (args, ctx) => {
|
|
33171
|
+
let statement;
|
|
33172
|
+
let functions;
|
|
33173
|
+
try {
|
|
33174
|
+
statement = JSON.parse(args[0] ?? "");
|
|
33175
|
+
functions = JSON.parse(args[1] ?? "[]");
|
|
33176
|
+
} catch {
|
|
33177
|
+
return { stdout: "", stderr: `bash: ${BG_COMMAND}: not a job
|
|
33178
|
+
`, exitCode: 2 };
|
|
33179
|
+
}
|
|
33180
|
+
const { shell } = shellOf$1(ctx);
|
|
33181
|
+
const script = { type: "Script", statements: [...functions, statement] };
|
|
33182
|
+
const job = startJob(host2, ctx, shell, script, typeof statement.sourceText === "string" ? statement.sourceText : "");
|
|
33183
|
+
shell.jobs.set(job.pid, job);
|
|
33184
|
+
shell.order.push(job.pid);
|
|
33185
|
+
ctx.env.set(LAST_JOB_VAR, String(job.pid));
|
|
33186
|
+
return { stdout: "", stderr: "", exitCode: 0 };
|
|
33187
|
+
}));
|
|
33188
|
+
bash.registerCommand(defineCommand(WAIT_COMMAND, async (args, ctx) => {
|
|
33189
|
+
const { id, shell } = shellOf$1(ctx);
|
|
33190
|
+
let stderr = "";
|
|
33191
|
+
let status = 0;
|
|
33192
|
+
let next = false;
|
|
33193
|
+
const targets = [];
|
|
33194
|
+
for (const arg of args) {
|
|
33195
|
+
if (arg === "-n") next = true;
|
|
33196
|
+
else if (arg === "-f" || arg === "--") continue;
|
|
33197
|
+
else targets.push(arg);
|
|
33198
|
+
}
|
|
33199
|
+
const aborted = new Promise((resolve2) => {
|
|
33200
|
+
var _a2, _b2;
|
|
33201
|
+
if ((_a2 = ctx.signal) == null ? void 0 : _a2.aborted) resolve2("aborted");
|
|
33202
|
+
(_b2 = ctx.signal) == null ? void 0 : _b2.addEventListener("abort", () => resolve2("aborted"), { once: true });
|
|
33203
|
+
});
|
|
33204
|
+
const running = () => shell.order.map((pid) => shell.jobs.get(pid)).filter((job) => job !== void 0 && job.status === null);
|
|
33205
|
+
const reap = (job) => {
|
|
33206
|
+
shell.jobs.delete(job.pid);
|
|
33207
|
+
shell.order = shell.order.filter((pid) => pid !== job.pid);
|
|
33208
|
+
};
|
|
33209
|
+
if (next) {
|
|
33210
|
+
const pending = targets.length > 0 ? targets.map((target) => shell.jobs.get(Number(target))).filter((job) => job !== void 0) : shell.order.map((pid) => shell.jobs.get(pid)).filter((job) => job !== void 0);
|
|
33211
|
+
if (pending.length === 0) status = 127;
|
|
33212
|
+
else {
|
|
33213
|
+
const first = await Promise.race([...pending.map((job) => job.done.then(() => job)), aborted]);
|
|
33214
|
+
if (first === "aborted") status = 130;
|
|
33215
|
+
else {
|
|
33216
|
+
status = first.status ?? 0;
|
|
33217
|
+
reap(first);
|
|
33218
|
+
}
|
|
33219
|
+
}
|
|
33220
|
+
} else if (targets.length === 0) {
|
|
33221
|
+
for (let jobs = running(); jobs.length > 0; jobs = running()) {
|
|
33222
|
+
if (await Promise.race([Promise.all(jobs.map((job) => job.done)), aborted]) === "aborted") {
|
|
33223
|
+
status = 130;
|
|
33224
|
+
break;
|
|
33225
|
+
}
|
|
33226
|
+
}
|
|
33227
|
+
for (const pid of [...shell.order]) {
|
|
33228
|
+
const job = shell.jobs.get(pid);
|
|
33229
|
+
if (job && job.status !== null) reap(job);
|
|
33230
|
+
}
|
|
33231
|
+
} else {
|
|
33232
|
+
for (const target of targets) {
|
|
33233
|
+
if (target.startsWith("%")) {
|
|
33234
|
+
stderr += `bash: wait: ${target}: no such job
|
|
33235
|
+
`;
|
|
33236
|
+
status = 127;
|
|
33237
|
+
continue;
|
|
33238
|
+
}
|
|
33239
|
+
const pid = Number(target);
|
|
33240
|
+
const job = Number.isInteger(pid) ? shell.jobs.get(pid) : void 0;
|
|
33241
|
+
if (!job) {
|
|
33242
|
+
stderr += Number.isInteger(pid) ? `bash: wait: pid ${target} is not a child of this shell
|
|
33243
|
+
` : `bash: wait: \`${target}': not a pid or valid job spec
|
|
33244
|
+
`;
|
|
33245
|
+
status = 127;
|
|
33246
|
+
continue;
|
|
33247
|
+
}
|
|
33248
|
+
const outcome = await Promise.race([job.done, aborted]);
|
|
33249
|
+
if (outcome === "aborted") {
|
|
33250
|
+
status = 130;
|
|
33251
|
+
break;
|
|
33252
|
+
}
|
|
33253
|
+
status = outcome;
|
|
33254
|
+
reap(job);
|
|
33255
|
+
}
|
|
33256
|
+
}
|
|
33257
|
+
const held = flush(shell);
|
|
33258
|
+
if (shell.jobs.size === 0) shells$1.delete(id);
|
|
33259
|
+
return { stdout: held.stdout, stderr: held.stderr + stderr, exitCode: status };
|
|
33260
|
+
}));
|
|
33261
|
+
bash.registerCommand(defineCommand("kill", async (args) => {
|
|
33262
|
+
let signal = "SIGTERM";
|
|
33263
|
+
let index2 = 0;
|
|
33264
|
+
if (args[0] === "-l" || args[0] === "-L") {
|
|
33265
|
+
const names2 = Object.entries(__substrateSignals).sort((a, b) => a[1] - b[1]).map(([name]) => name.slice(3));
|
|
33266
|
+
if (args[1] !== void 0) {
|
|
33267
|
+
const number = Number(args[1]);
|
|
33268
|
+
const name = Number.isInteger(number) ? __substrateSignalNames[number > 128 ? number - 128 : number] : signalName(args[1]);
|
|
33269
|
+
if (!name) return { stdout: "", stderr: `bash: kill: ${args[1]}: invalid signal specification
|
|
33270
|
+
`, exitCode: 1 };
|
|
33271
|
+
return { stdout: `${Number.isInteger(number) ? name.slice(3) : __substrateSignals[name]}
|
|
33272
|
+
`, stderr: "", exitCode: 0 };
|
|
33273
|
+
}
|
|
33274
|
+
return { stdout: `${names2.join(" ")}
|
|
33275
|
+
`, stderr: "", exitCode: 0 };
|
|
33276
|
+
}
|
|
33277
|
+
if (args[0] === "-s" || args[0] === "-n") {
|
|
33278
|
+
const name = args[1] === void 0 ? null : signalName(args[1]);
|
|
33279
|
+
if (!name) return { stdout: "", stderr: `bash: kill: ${args[1] ?? ""}: invalid signal specification
|
|
33280
|
+
`, exitCode: 1 };
|
|
33281
|
+
signal = name;
|
|
33282
|
+
index2 = 2;
|
|
33283
|
+
} else if (args[0] !== void 0 && args[0].startsWith("-") && args[0] !== "--") {
|
|
33284
|
+
const name = signalName(args[0]);
|
|
33285
|
+
if (!name) return { stdout: "", stderr: `bash: kill: ${args[0].slice(1)}: invalid signal specification
|
|
33286
|
+
`, exitCode: 1 };
|
|
33287
|
+
signal = name;
|
|
33288
|
+
index2 = 1;
|
|
33289
|
+
}
|
|
33290
|
+
if (args[index2] === "--") index2 += 1;
|
|
33291
|
+
const targets = args.slice(index2);
|
|
33292
|
+
if (targets.length === 0) return { stdout: "", stderr: "bash: kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]\n", exitCode: 2 };
|
|
33293
|
+
let stderr = "";
|
|
33294
|
+
let status = 0;
|
|
33295
|
+
for (const target of targets) {
|
|
33296
|
+
if (target.startsWith("%")) {
|
|
33297
|
+
stderr += `bash: kill: ${target}: no such job
|
|
33298
|
+
`;
|
|
33299
|
+
status = 1;
|
|
33300
|
+
continue;
|
|
33301
|
+
}
|
|
33302
|
+
if (!/^-?\d+$/u.test(target)) {
|
|
33303
|
+
stderr += `bash: kill: ${target}: arguments must be process or job IDs
|
|
33304
|
+
`;
|
|
33305
|
+
status = 1;
|
|
33306
|
+
continue;
|
|
33307
|
+
}
|
|
33308
|
+
const pid = Math.abs(Number(target));
|
|
33309
|
+
if (!deliver(pid, signal)) {
|
|
33310
|
+
stderr += `bash: kill: (${target}) - No such process
|
|
33311
|
+
`;
|
|
33312
|
+
status = 1;
|
|
33313
|
+
}
|
|
33314
|
+
}
|
|
33315
|
+
return { stdout: "", stderr, exitCode: status };
|
|
33316
|
+
}));
|
|
33317
|
+
bash.registerCommand(defineCommand("disown", async (args, ctx) => {
|
|
33318
|
+
const { shell } = shellOf$1(ctx);
|
|
33319
|
+
const pids = args.filter((arg) => !arg.startsWith("-")).map(Number);
|
|
33320
|
+
const all = args.includes("-a");
|
|
33321
|
+
const chosen = all ? [...shell.order] : pids.length > 0 ? pids : shell.order.slice(-1);
|
|
33322
|
+
for (const pid of chosen) {
|
|
33323
|
+
shell.jobs.delete(pid);
|
|
33324
|
+
shell.order = shell.order.filter((own) => own !== pid);
|
|
33325
|
+
}
|
|
33326
|
+
return { stdout: "", stderr: "", exitCode: 0 };
|
|
33327
|
+
}));
|
|
33328
|
+
}
|
|
33329
|
+
function deliver(pid, signal) {
|
|
33330
|
+
const child = __substrateChildren.get(pid);
|
|
33331
|
+
const childLive = child !== void 0 && child.exitCode === null && child.signalCode === null;
|
|
33332
|
+
if (signal === "0") return childLive || pidIsLive(pid);
|
|
33333
|
+
if (childLive) return child.kill(signal);
|
|
33334
|
+
const token = tokenOfPid(pid);
|
|
33335
|
+
if (token !== null && __signalOwnedProcess(token, signal)) return true;
|
|
33336
|
+
return signalPid(pid, signal);
|
|
33337
|
+
}
|
|
32888
33338
|
if (typeof globalThis.process === "undefined") {
|
|
32889
33339
|
globalThis.process = {
|
|
32890
33340
|
env: {
|
|
@@ -33541,6 +33991,7 @@ ${error.stack || ""}` : String(error);
|
|
|
33541
33991
|
},
|
|
33542
33992
|
customCommands: [nodeCommand, npmCommand]
|
|
33543
33993
|
});
|
|
33994
|
+
installShellJobs(bashInstance, { runTokenOf, runStreamsFor, registerRunStreams, releaseRunStreams });
|
|
33544
33995
|
shells.set(tree2, { bash: bashInstance, adapter: vfsAdapter });
|
|
33545
33996
|
if (processRunnerInstalled) return;
|
|
33546
33997
|
processRunnerInstalled = true;
|
|
@@ -34079,17 +34530,17 @@ function startChildRun(request) {
|
|
|
34079
34530
|
stdinSink.push(chunk);
|
|
34080
34531
|
}
|
|
34081
34532
|
};
|
|
34082
|
-
|
|
34083
|
-
|
|
34533
|
+
const streamedOut = [];
|
|
34534
|
+
const streamedErr = [];
|
|
34084
34535
|
const streams2 = {
|
|
34085
34536
|
onStdout: (data2) => {
|
|
34086
34537
|
var _a3;
|
|
34087
|
-
streamedOut
|
|
34538
|
+
streamedOut.push(data2);
|
|
34088
34539
|
(_a3 = request.stdout) == null ? void 0 : _a3.call(request, data2);
|
|
34089
34540
|
},
|
|
34090
34541
|
onStderr: (data2) => {
|
|
34091
34542
|
var _a3;
|
|
34092
|
-
streamedErr
|
|
34543
|
+
streamedErr.push(data2);
|
|
34093
34544
|
(_a3 = request.stderr) == null ? void 0 : _a3.call(request, data2);
|
|
34094
34545
|
},
|
|
34095
34546
|
signal: controller.signal,
|
|
@@ -34171,8 +34622,10 @@ function startChildRun(request) {
|
|
|
34171
34622
|
outcome = { stdout: "", stderr: `${error instanceof Error ? error.message : String(error)}
|
|
34172
34623
|
`, exitCode: 1 };
|
|
34173
34624
|
}
|
|
34174
|
-
|
|
34175
|
-
|
|
34625
|
+
const restOut = unstreamedOutput(outcome.stdout, streamedOut);
|
|
34626
|
+
const restErr = unstreamedOutput(outcome.stderr, streamedErr);
|
|
34627
|
+
if (restOut) (_a3 = request.stdout) == null ? void 0 : _a3.call(request, restOut);
|
|
34628
|
+
if (restErr) (_b2 = request.stderr) == null ? void 0 : _b2.call(request, restErr);
|
|
34176
34629
|
end(outcome.exitCode, outcome.signal ?? null);
|
|
34177
34630
|
})();
|
|
34178
34631
|
};
|
|
@@ -37129,6 +37582,26 @@ function transformEsmToCjsRegex(code2) {
|
|
|
37129
37582
|
);
|
|
37130
37583
|
return transformed;
|
|
37131
37584
|
}
|
|
37585
|
+
function canStripTypes() {
|
|
37586
|
+
return hostAmaro() !== null;
|
|
37587
|
+
}
|
|
37588
|
+
function startedWith(process2, option) {
|
|
37589
|
+
var _a2;
|
|
37590
|
+
if (Array.isArray(process2.execArgv) && process2.execArgv.includes(option)) return true;
|
|
37591
|
+
const nodeOptions = (_a2 = process2.env) == null ? void 0 : _a2.NODE_OPTIONS;
|
|
37592
|
+
return typeof nodeOptions === "string" && nodeOptions.split(/\s+/u).includes(option);
|
|
37593
|
+
}
|
|
37594
|
+
function transformsTypes(process2) {
|
|
37595
|
+
return startedWith(process2, "--experimental-transform-types");
|
|
37596
|
+
}
|
|
37597
|
+
function stripModuleTypes(source, filename, process2) {
|
|
37598
|
+
const typescript = loadNodeLibFor(process2, "internal/modules/typescript");
|
|
37599
|
+
const transform2 = transformsTypes(process2);
|
|
37600
|
+
return withOptionValues({
|
|
37601
|
+
"--experimental-transform-types": transform2,
|
|
37602
|
+
"--enable-source-maps": transform2 || startedWith(process2, "--enable-source-maps")
|
|
37603
|
+
}, () => typescript.stripTypeScriptModuleTypes(source, filename));
|
|
37604
|
+
}
|
|
37132
37605
|
function walkAst(node, callback) {
|
|
37133
37606
|
if (!node || typeof node !== "object") return;
|
|
37134
37607
|
if (typeof node.type === "string") {
|
|
@@ -37162,6 +37635,14 @@ function __substrateGuestConstructor(Constructor, process2) {
|
|
|
37162
37635
|
return __substrateFunctionScope(__substrateGuestGlobal(process2), String(compiled));
|
|
37163
37636
|
} });
|
|
37164
37637
|
}
|
|
37638
|
+
function __substrateModuleTypes(code2, resolvedPath, format2, process2) {
|
|
37639
|
+
const typescript = format2 === void 0 ? /[.](?:ts|mts|cts)$/u.test(resolvedPath) && !resolvedPath.endsWith(".d.ts") : format2 === "typescript" || format2 === "commonjs-typescript" || format2 === "module-typescript";
|
|
37640
|
+
if (!typescript) return code2;
|
|
37641
|
+
const registered = globalThis.__substrateStripTypes;
|
|
37642
|
+
if (typeof registered === "function") return registered(code2, resolvedPath);
|
|
37643
|
+
if (!canStripTypes()) return code2;
|
|
37644
|
+
return stripModuleTypes(code2, resolvedPath, process2);
|
|
37645
|
+
}
|
|
37165
37646
|
function __substrateSourceURL(resolvedPath) {
|
|
37166
37647
|
let name = resolvedPath;
|
|
37167
37648
|
if (name.startsWith("file://")) {
|
|
@@ -37504,11 +37985,11 @@ async function __substrateImportChain(hooks, id, parentURL, moduleRequire) {
|
|
|
37504
37985
|
const doors = moduleRequire;
|
|
37505
37986
|
const resolved = hooks.hasAsyncResolve ? await hooks.resolve(id, parentURL, void 0, (specifier) => ({ url: doors.__resolveToURL(specifier) })) : { url: doors.__resolveToURL(id), format: void 0 };
|
|
37506
37987
|
if (!hooks.hasAsyncLoad) return doors.__loadFromURL(resolved.url, resolved.format);
|
|
37507
|
-
const
|
|
37988
|
+
const loaded2 = await hooks.load(resolved.url, resolved.format, void 0, (url2, context2) => ({
|
|
37508
37989
|
source: doors.__readFromURL(url2),
|
|
37509
37990
|
format: context2.format
|
|
37510
37991
|
}));
|
|
37511
|
-
return doors.__loadFromURL(resolved.url,
|
|
37992
|
+
return doors.__loadFromURL(resolved.url, loaded2.format ?? resolved.format, loaded2.source ?? void 0);
|
|
37512
37993
|
}
|
|
37513
37994
|
function createDynamicImport(moduleRequire, process2, parentURL) {
|
|
37514
37995
|
return async (specifier) => {
|
|
@@ -38397,14 +38878,14 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
38397
38878
|
let source = resolvedAs == null ? void 0 : resolvedAs.source;
|
|
38398
38879
|
if (__hooks && __hooks.hasSyncLoad && source === void 0) {
|
|
38399
38880
|
const url2 = (resolvedAs == null ? void 0 : resolvedAs.url) ?? __hooks.sync.convertCJSFilenameToURL(resolvedPath);
|
|
38400
|
-
const
|
|
38881
|
+
const loaded2 = __hooks.sync.loadWithHooks(url2, format2, void 0, CJS_CONDITIONS, (urlFromHook, context2) => ({
|
|
38401
38882
|
// Node's `getDefaultLoad`: a URL the chain changed is read from the
|
|
38402
38883
|
// file it names, not from the one the loader started with.
|
|
38403
38884
|
source: urlFromHook === url2 ? defaultSource() : vfs2.readFileSync(__hooks.sync.convertURLToCJSFilename(urlFromHook), "utf8"),
|
|
38404
38885
|
format: context2.format
|
|
38405
38886
|
}));
|
|
38406
|
-
format2 =
|
|
38407
|
-
source =
|
|
38887
|
+
format2 = loaded2.format;
|
|
38888
|
+
source = loaded2.source;
|
|
38408
38889
|
}
|
|
38409
38890
|
if (format2 === "json" || format2 === void 0 && resolvedPath.endsWith(".json")) {
|
|
38410
38891
|
module.exports = JSON.parse(source === void 0 || source === null ? vfs2.readFileSync(resolvedPath, "utf8") : String(source));
|
|
@@ -38417,22 +38898,18 @@ function createRequire(vfs2, fsShim, process2, currentDir, moduleCache, options,
|
|
|
38417
38898
|
return module;
|
|
38418
38899
|
};
|
|
38419
38900
|
const prepareModuleCode = (rawCode, resolvedPath, format2) => {
|
|
38420
|
-
const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${simpleHash(rawCode)}`;
|
|
38901
|
+
const codeCacheKey = `${resolvedPath}|${format2 ?? ""}|${transformsTypes(process2) ? "transform-types|" : ""}${simpleHash(rawCode)}`;
|
|
38421
38902
|
let code2 = processedCodeCache == null ? void 0 : processedCodeCache.get(codeCacheKey);
|
|
38422
38903
|
if (!code2) {
|
|
38423
38904
|
code2 = rawCode;
|
|
38424
38905
|
if (code2.startsWith("#!")) {
|
|
38425
38906
|
code2 = code2.slice(code2.indexOf("\n") + 1);
|
|
38426
38907
|
}
|
|
38427
|
-
|
|
38428
|
-
|
|
38429
|
-
code2 = globalThis.__substrateStripTypes(code2, resolvedPath);
|
|
38430
|
-
}
|
|
38431
|
-
const __commonjs = format2 === "commonjs" || format2 === "commonjs-typescript" ? true : format2 === "module" || format2 === "module-typescript" ? false : resolvedPath.endsWith(".cjs");
|
|
38908
|
+
code2 = __substrateModuleTypes(code2, resolvedPath, format2, process2);
|
|
38909
|
+
const __commonjs = format2 === "commonjs" || format2 === "commonjs-typescript" ? true : format2 === "module" || format2 === "module-typescript" ? false : resolvedPath.endsWith(".cjs") || resolvedPath.endsWith(".cts");
|
|
38432
38910
|
if (!__commonjs) {
|
|
38433
38911
|
const lowered = transformEsmToCjs(code2, resolvedPath);
|
|
38434
|
-
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict"
|
|
38435
|
-
${lowered}`;
|
|
38912
|
+
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
|
|
38436
38913
|
} else {
|
|
38437
38914
|
code2 = transformDynamicImportsRegex(code2);
|
|
38438
38915
|
}
|
|
@@ -38545,9 +39022,9 @@ ${lowered}`;
|
|
|
38545
39022
|
const filename = url2 === defaultURL ? defaultFilename : hooks.sync.convertURLToCJSFilename(url2);
|
|
38546
39023
|
if (isBuiltin(filename)) {
|
|
38547
39024
|
if (hooks.hasSyncLoad) {
|
|
38548
|
-
const
|
|
38549
|
-
if (
|
|
38550
|
-
return loadModule(filename, { url: url2, format:
|
|
39025
|
+
const loaded2 = hooks.sync.loadWithHooks(url2, format2 || "builtin", void 0, CJS_CONDITIONS, (_urlFromHook, context2) => ({ source: null, format: context2.format }));
|
|
39026
|
+
if (loaded2.format && loaded2.format !== "builtin") {
|
|
39027
|
+
return loadModule(filename, { url: url2, format: loaded2.format, source: loaded2.source }).exports;
|
|
38551
39028
|
}
|
|
38552
39029
|
}
|
|
38553
39030
|
return requirePlain(filename);
|
|
@@ -38804,10 +39281,10 @@ class Runtime {
|
|
|
38804
39281
|
if (code2.startsWith("#!")) {
|
|
38805
39282
|
code2 = code2.slice(code2.indexOf("\n") + 1);
|
|
38806
39283
|
}
|
|
38807
|
-
|
|
39284
|
+
code2 = __substrateModuleTypes(code2, filename, void 0, this.process);
|
|
39285
|
+
if (!filename.endsWith(".cjs") && !filename.endsWith(".cts")) {
|
|
38808
39286
|
const lowered = transformEsmToCjs(code2, filename);
|
|
38809
|
-
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict"
|
|
38810
|
-
${lowered}`;
|
|
39287
|
+
code2 = lowered === code2 ? code2 : `${__substrateModuleMarker}"use strict";${lowered}`;
|
|
38811
39288
|
} else {
|
|
38812
39289
|
code2 = transformDynamicImportsRegex(code2);
|
|
38813
39290
|
}
|
|
@@ -39316,7 +39793,7 @@ class WorkerRuntime {
|
|
|
39316
39793
|
this.worker = new Worker(
|
|
39317
39794
|
new URL(
|
|
39318
39795
|
/* @vite-ignore */
|
|
39319
|
-
"/assets/runtime-worker-
|
|
39796
|
+
"/assets/runtime-worker-C-l9pCp3.js",
|
|
39320
39797
|
import.meta.url
|
|
39321
39798
|
),
|
|
39322
39799
|
{ type: "module" }
|
|
@@ -41691,7 +42168,7 @@ const _ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
41691
42168
|
finished = true;
|
|
41692
42169
|
this.controlledStreams.delete(id);
|
|
41693
42170
|
};
|
|
41694
|
-
const
|
|
42171
|
+
const flush2 = () => {
|
|
41695
42172
|
if (finished) return;
|
|
41696
42173
|
while (credits > 0 && queue.length > 0) {
|
|
41697
42174
|
credits -= 1;
|
|
@@ -41713,7 +42190,7 @@ const _ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
41713
42190
|
this.controlledStreams.set(id, {
|
|
41714
42191
|
pull: () => {
|
|
41715
42192
|
credits += 1;
|
|
41716
|
-
|
|
42193
|
+
flush2();
|
|
41717
42194
|
},
|
|
41718
42195
|
cancel: () => {
|
|
41719
42196
|
if (finished) return;
|
|
@@ -41728,11 +42205,11 @@ const _ServerBridge = class _ServerBridge extends EventEmitter {
|
|
|
41728
42205
|
chunk: (chunk) => {
|
|
41729
42206
|
if (finished) return;
|
|
41730
42207
|
for (let at2 = 0; at2 < chunk.byteLength; at2 += FLOW_MAX_CHUNK_BYTES) queue.push(chunk.slice(at2, at2 + FLOW_MAX_CHUNK_BYTES));
|
|
41731
|
-
|
|
42208
|
+
flush2();
|
|
41732
42209
|
},
|
|
41733
42210
|
end: () => {
|
|
41734
42211
|
upstreamEnded = true;
|
|
41735
|
-
|
|
42212
|
+
flush2();
|
|
41736
42213
|
}
|
|
41737
42214
|
}, { signal: abort.signal, control: (p, r) => {
|
|
41738
42215
|
pause = p;
|