emsdk-env 0.10.0 → 0.11.0
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/build-BbwVl0T6.js +1379 -0
- package/dist/build-BbwVl0T6.js.map +1 -0
- package/dist/build-TpHGBYTu.cjs +1388 -0
- package/dist/build-TpHGBYTu.cjs.map +1 -0
- package/dist/build.d.ts +22 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/commands.d.ts +14 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/emsdk.d.ts +22 -0
- package/dist/emsdk.d.ts.map +1 -0
- package/dist/env.d.ts +16 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/fs-utils.d.ts +13 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/generated/packageMetadata.d.ts +18 -0
- package/dist/generated/packageMetadata.d.ts.map +1 -0
- package/dist/index.cjs +11 -14
- package/dist/index.d.ts +17 -338
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +10 -15
- package/dist/logger.d.ts +13 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/{vite.d.ts → types.d.ts} +299 -268
- package/dist/types.d.ts.map +1 -0
- package/dist/vite/index.d.ts +24 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/logger.d.ts +14 -0
- package/dist/vite/logger.d.ts.map +1 -0
- package/dist/vite/types.d.ts +17 -0
- package/dist/vite/types.d.ts.map +1 -0
- package/dist/vite.cjs +735 -712
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +729 -712
- package/dist/vite.mjs.map +1 -1
- package/package.json +22 -21
- package/dist/build-BE9Z95iJ.js +0 -1668
- package/dist/build-BE9Z95iJ.js.map +0 -1
- package/dist/build-BGtsNe6D.cjs +0 -1689
- package/dist/build-BGtsNe6D.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-TpHGBYTu.cjs","names":[],"sources":["../node_modules/async-primitives/dist/index.mjs","../src/commands.ts","../src/fs-utils.ts","../src/emsdk.ts","../src/env.ts","../src/logger.ts","../src/build.ts"],"sourcesContent":["/*!\n* name: async-primitives\n* version: 1.7.0\n* description: A collection of primitive functions for asynchronous operations\n* author: Kouji Matsui (@kekyo@mi.kekyo.net)\n* license: MIT\n* repository.url: https://github.com/kekyo/async-primitives.git\n* git.commit.hash: 9472fbd5310b92690d84aaafb897429a04c013c5\n*/\n//#region src/primitives/internal/utils.ts\n/**\n* A no-op Releasable object that does nothing when released or disposed\n*/\nvar __NOOP_HANDLER = () => {};\nvar __NOOP_RELEASABLE = {\n\trelease: __NOOP_HANDLER,\n\t[Symbol.dispose]: __NOOP_HANDLER\n};\n//#endregion\n//#region src/primitives/abort-hook.ts\nvar toAbortError = (reason) => {\n\tif (reason instanceof Error) return reason;\n\tif (typeof reason === \"string\") return new Error(reason);\n\treturn /* @__PURE__ */ new Error(\"Operation aborted\");\n};\n/**\n* Hooks up an abort handler to an AbortSignal and returns a handle for early cleanup\n* @param signal - The AbortSignal to hook up to\n* @param callback - The callback to call when the signal is aborted\n* @returns A Releasable handle that can be used to remove the abort listener early\n*/\nvar onAbort = (signal, callback) => {\n\tif (!signal) return __NOOP_RELEASABLE;\n\tif (signal.aborted) {\n\t\ttry {\n\t\t\tcallback(toAbortError(signal.reason));\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"AbortHook callback error: \", error);\n\t\t}\n\t\treturn __NOOP_RELEASABLE;\n\t}\n\tlet abortHandler = () => {\n\t\tif (abortHandler) {\n\t\t\tconst reason = signal.reason;\n\t\t\tsignal.removeEventListener(\"abort\", abortHandler);\n\t\t\tabortHandler = void 0;\n\t\t\ttry {\n\t\t\t\tcallback(toAbortError(reason));\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(\"AbortHook callback error: \", error);\n\t\t\t}\n\t\t}\n\t};\n\tconst release = () => {\n\t\tif (abortHandler) {\n\t\t\tsignal.removeEventListener(\"abort\", abortHandler);\n\t\t\tabortHandler = void 0;\n\t\t}\n\t};\n\tsignal.addEventListener(\"abort\", abortHandler, { once: true });\n\treturn {\n\t\trelease,\n\t\t[Symbol.dispose]: release\n\t};\n};\n//#endregion\n//#region src/primitives/delay.ts\n/**\n* Helper function to create a delay\n* @param msec - The number of milliseconds to delay\n* @param signal - Optional AbortSignal to cancel the delay\n* @returns A promise that resolves after the delay or rejects if aborted\n*/\nvar delay = (msec, signal) => {\n\tif (signal) {\n\t\tif (signal.aborted) throw new Error(\"Delay was aborted\");\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst abortHandle = onAbort(signal, () => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\treject(/* @__PURE__ */ new Error(\"Delay was aborted\"));\n\t\t\t});\n\t\t\tconst timeoutId = setTimeout(() => {\n\t\t\t\tabortHandle.release();\n\t\t\t\tresolve();\n\t\t\t}, msec);\n\t\t});\n\t} else return new Promise((resolve) => {\n\t\tsetTimeout(resolve, msec);\n\t});\n};\n//#endregion\n//#region src/primitives/defer.ts\nvar runtimeGlobal$1 = globalThis;\nvar defer = (fn) => {\n\tconst setImmediateHandler = runtimeGlobal$1.setImmediate;\n\tif (typeof setImmediateHandler === \"function\") {\n\t\tsetImmediateHandler(fn);\n\t\treturn;\n\t}\n\tglobalThis.setTimeout(fn, 0);\n};\n//#endregion\n//#region src/primitives/mutex.ts\nvar ABORTED_ERROR$2 = () => /* @__PURE__ */ new Error(\"Lock acquisition was aborted\");\n/**\n* Creates a new LockHandle instance\n* @param releaseCallback Callback function to release the lock\n* @returns A LockHandle object with release and dispose functionality\n*/\nvar createLockHandle = (releaseCallback) => {\n\tlet isActive = true;\n\tconst release = () => {\n\t\tif (!isActive) return;\n\t\tisActive = false;\n\t\treleaseCallback();\n\t};\n\treturn {\n\t\tget isActive() {\n\t\t\treturn isActive;\n\t\t},\n\t\trelease,\n\t\t[Symbol.dispose]: release\n\t};\n};\n/**\n* Creates a new Mutex instance\n* @param maxConsecutiveCalls - The maximum number of consecutive calls to the lockAsync method before yielding control to the next item in the queue\n* @returns A new Mutex for promise-based mutex operations\n*/\nvar createMutex = (maxConsecutiveCalls = 20) => {\n\tlet isLocked = false;\n\tconst queue = [];\n\tlet count = 0;\n\tconst processQueue = () => {\n\t\tvar _item$signal;\n\t\tif (isLocked || queue.length === 0) return;\n\t\tconst item = queue.shift();\n\t\tif ((_item$signal = item.signal) === null || _item$signal === void 0 ? void 0 : _item$signal.aborted) {\n\t\t\titem.reject(ABORTED_ERROR$2());\n\t\t\tscheduleNextProcess();\n\t\t\treturn;\n\t\t}\n\t\tisLocked = true;\n\t\tconst lockHandle = createLockHandle(releaseLock);\n\t\titem.resolve(lockHandle);\n\t};\n\tconst scheduleNextProcess = () => {\n\t\tcount++;\n\t\tif (count >= maxConsecutiveCalls) {\n\t\t\tcount = 0;\n\t\t\tdefer(processQueue);\n\t\t} else processQueue();\n\t};\n\tconst releaseLock = () => {\n\t\tif (!isLocked) return;\n\t\tisLocked = false;\n\t\tscheduleNextProcess();\n\t};\n\tconst removeFromQueue = (item) => {\n\t\tconst index = queue.indexOf(item);\n\t\tif (index !== -1) queue.splice(index, 1);\n\t};\n\tconst lock = async (signal) => {\n\t\tif (signal) {\n\t\t\tif (signal.aborted) throw ABORTED_ERROR$2();\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst queueItem = {\n\t\t\t\t\tresolve: void 0,\n\t\t\t\t\treject: void 0,\n\t\t\t\t\tsignal\n\t\t\t\t};\n\t\t\t\tconst abortHandle = onAbort(signal, () => {\n\t\t\t\t\tremoveFromQueue(queueItem);\n\t\t\t\t\treject(ABORTED_ERROR$2());\n\t\t\t\t});\n\t\t\t\tqueueItem.resolve = (handle) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\tresolve(handle);\n\t\t\t\t};\n\t\t\t\tqueueItem.reject = (error) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\treject(error);\n\t\t\t\t};\n\t\t\t\tqueue.push(queueItem);\n\t\t\t\tprocessQueue();\n\t\t\t});\n\t\t} else return new Promise((resolve, reject) => {\n\t\t\tqueue.push({\n\t\t\t\tresolve,\n\t\t\t\treject\n\t\t\t});\n\t\t\tprocessQueue();\n\t\t});\n\t};\n\treturn {\n\t\tlock,\n\t\twaiter: { wait: lock },\n\t\tget isLocked() {\n\t\t\treturn isLocked;\n\t\t},\n\t\tget pendingCount() {\n\t\t\treturn queue.length;\n\t\t}\n\t};\n};\n//#endregion\n//#region src/primitives/deferred.ts\n/**\n* Creates a new deferred object\n* @param T - The type of the result\n* @param signal - Optional AbortSignal for cancelling the wait\n* @returns A deferred object with a promise, resolve, and reject methods\n*/\nvar createDeferred = (signal) => {\n\tlet resolve;\n\tlet reject;\n\tconst promise = new Promise((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\tconst disposer = onAbort(signal, () => {\n\t\tconst _reject = reject;\n\t\tif (_reject) {\n\t\t\tresolve = void 0;\n\t\t\treject = void 0;\n\t\t\t_reject(/* @__PURE__ */ new Error(\"Deferred aborted\"));\n\t\t}\n\t});\n\treturn {\n\t\tpromise,\n\t\tresolve: (value) => {\n\t\t\tconst _resolve = resolve;\n\t\t\tif (_resolve) {\n\t\t\t\tresolve = void 0;\n\t\t\t\treject = void 0;\n\t\t\t\tdisposer.release();\n\t\t\t\t_resolve(value);\n\t\t\t}\n\t\t},\n\t\treject: (error) => {\n\t\t\tconst _reject = reject;\n\t\t\tif (_reject) {\n\t\t\t\tresolve = void 0;\n\t\t\t\treject = void 0;\n\t\t\t\tdisposer.release();\n\t\t\t\t_reject(error);\n\t\t\t}\n\t\t}\n\t};\n};\n//#endregion\n//#region src/primitives/conditional.ts\nvar __NOOP_DUMMY_HANDLE = {\n\tget isActive() {\n\t\treturn false;\n\t},\n\trelease: __NOOP_HANDLER,\n\t[Symbol.dispose]: __NOOP_HANDLER\n};\n/**\n* Creates a conditional that can be automatically triggered\n* @returns A conditional that can be automatically triggered\n*/\nvar createConditional = () => {\n\tconst waiters = [];\n\tconst trigger = () => {\n\t\tif (waiters.length >= 1) waiters.shift().resolve();\n\t};\n\tconst wait = async (signal) => {\n\t\tif (signal === null || signal === void 0 ? void 0 : signal.aborted) throw new Error(\"Conditional aborted\");\n\t\tconst waiter = createDeferred();\n\t\twaiters.push(waiter);\n\t\tconst disposer = onAbort(signal, () => {\n\t\t\twaiters.splice(waiters.indexOf(waiter), 1);\n\t\t\twaiter.reject(/* @__PURE__ */ new Error(\"Conditional aborted\"));\n\t\t});\n\t\ttry {\n\t\t\tawait waiter.promise;\n\t\t} finally {\n\t\t\tdisposer.release();\n\t\t}\n\t\treturn __NOOP_DUMMY_HANDLE;\n\t};\n\treturn {\n\t\ttrigger,\n\t\twait,\n\t\twaiter: { wait }\n\t};\n};\n/**\n* Creates a conditional that can be manually set and reset\n* @param initialState - Optional initial state of the conditional (Default: false, dropped)\n* @returns A conditional that can be manually set and reset\n*/\nvar createManuallyConditional = (initialState) => {\n\tconst waiters = [];\n\tlet raised = initialState !== null && initialState !== void 0 ? initialState : false;\n\tconst trigger = () => {\n\t\traised = false;\n\t\tconst waiter = waiters.shift();\n\t\tif (waiter) {\n\t\t\twaiter.resolve();\n\t\t\traised = false;\n\t\t}\n\t};\n\tconst raise = () => {\n\t\twhile (waiters.length >= 1) {\n\t\t\traised = true;\n\t\t\twaiters.shift().resolve();\n\t\t}\n\t\traised = true;\n\t};\n\tconst drop = () => {\n\t\traised = false;\n\t};\n\tconst wait = async (signal) => {\n\t\tif (raised) return __NOOP_DUMMY_HANDLE;\n\t\tif (signal === null || signal === void 0 ? void 0 : signal.aborted) throw new Error(\"Conditional aborted\");\n\t\tconst waiter = createDeferred();\n\t\twaiters.push(waiter);\n\t\tconst disposer = onAbort(signal, () => {\n\t\t\twaiters.splice(waiters.indexOf(waiter), 1);\n\t\t\twaiter.reject(/* @__PURE__ */ new Error(\"Conditional aborted\"));\n\t\t});\n\t\ttry {\n\t\t\tawait waiter.promise;\n\t\t} finally {\n\t\t\tdisposer.release();\n\t\t}\n\t\treturn __NOOP_DUMMY_HANDLE;\n\t};\n\treturn {\n\t\ttrigger,\n\t\traise,\n\t\tdrop,\n\t\twait,\n\t\twaiter: { wait }\n\t};\n};\n//#endregion\n//#region src/primitives/deferred-generator.ts\n/**\n* Creates a new deferred generator object\n* @param T - The type of the yielded values\n* @param options - Optional options for the deferred generator\n* @returns A deferred generator object with an async generator and control functions\n*/\nvar createDeferredGenerator = (options) => {\n\tconst maxItemReserved = options === null || options === void 0 ? void 0 : options.maxItemReserved;\n\tconst signal = options === null || options === void 0 ? void 0 : options.signal;\n\tconst queue = [];\n\tconst arrived = createManuallyConditional();\n\tconst canReserve = maxItemReserved ? createManuallyConditional(true) : void 0;\n\tconst generator = (async function* () {\n\t\twhile (true) {\n\t\t\twhile (true) {\n\t\t\t\tconst item = queue.shift();\n\t\t\t\tif (maxItemReserved && queue.length === maxItemReserved - 1) canReserve.raise();\n\t\t\t\tif (!item) break;\n\t\t\t\tswitch (item.kind) {\n\t\t\t\t\tcase \"value\":\n\t\t\t\t\t\tyield item.value;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"completed\": return;\n\t\t\t\t\tcase \"error\": throw item.error;\n\t\t\t\t}\n\t\t\t\tif (signal === null || signal === void 0 ? void 0 : signal.aborted) throw new Error(\"Deferred generator aborted\");\n\t\t\t}\n\t\t\tarrived.drop();\n\t\t\ttry {\n\t\t\t\tawait arrived.wait(signal);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && error.message === \"Conditional aborted\") error.message = \"Deferred generator aborted\";\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t})();\n\tconst enqueue = async (item, signal) => {\n\t\twhile (true) {\n\t\t\tif (!maxItemReserved || queue.length < maxItemReserved) {\n\t\t\t\tconst remains = queue.push(item);\n\t\t\t\tif (remains === 1) arrived.raise();\n\t\t\t\tif (remains === maxItemReserved) canReserve.drop();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait canReserve.wait(signal);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && error.message === \"Conditional aborted\") error.message = \"Deferred generator aborted\";\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t};\n\treturn {\n\t\tgenerator,\n\t\tyield: (value, signal) => enqueue({\n\t\t\tkind: \"value\",\n\t\t\tvalue\n\t\t}, signal),\n\t\treturn: (signal) => enqueue({ kind: \"completed\" }, signal),\n\t\tthrow: (error, signal) => enqueue({\n\t\t\tkind: \"error\",\n\t\t\terror\n\t\t}, signal)\n\t};\n};\n//#endregion\n//#region src/primitives/internal/logical-context.ts\nvar runtimeGlobal = globalThis;\nvar LOGICAL_CONTEXT_HOOK = Symbol(\"logical-context-hook\");\nvar isHooked = (callback) => {\n\treturn callback[LOGICAL_CONTEXT_HOOK] === true;\n};\nvar markAsHooked = (callback) => {\n\tcallback[LOGICAL_CONTEXT_HOOK] = true;\n\treturn callback;\n};\nvar createLogicalContext = (id) => {\n\treturn {\n\t\tid,\n\t\tdata: /* @__PURE__ */ new Map()\n\t};\n};\nvar currentLogicalContext = createLogicalContext(Symbol(\"[root]\"));\nvar setCurrentLogicalContext = (context) => {\n\tcurrentLogicalContext = context;\n};\nvar trampoline = (adjustment, callback, thisArg, ...args) => {\n\tconst previousLogicalContext = currentLogicalContext;\n\tcurrentLogicalContext = adjustment.contextToUse;\n\ttry {\n\t\treturn callback.call(thisArg, ...args);\n\t} finally {\n\t\tadjustment.contextAfter = currentLogicalContext;\n\t\tcurrentLogicalContext = previousLogicalContext;\n\t}\n};\nvar isPrepared = false;\nvar prepareRuntimeHooks = () => {\n\tif (typeof globalThis.setTimeout !== \"undefined\" && !isHooked(globalThis.setTimeout)) {\n\t\tconst __setTimeout = globalThis.setTimeout;\n\t\tglobalThis.setTimeout = markAsHooked(((handler, timeout, ...args) => {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __setTimeout((...callbackArgs) => {\n\t\t\t\ttrampoline({ contextToUse: capturedLogicalContext }, handler, void 0, ...callbackArgs);\n\t\t\t}, timeout, ...args);\n\t\t}));\n\t}\n\tif (typeof globalThis.setInterval !== \"undefined\" && !isHooked(globalThis.setInterval)) {\n\t\tconst __setInterval = globalThis.setInterval;\n\t\tglobalThis.setInterval = markAsHooked(((handler, timeout, ...args) => {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __setInterval((...callbackArgs) => {\n\t\t\t\ttrampoline({ contextToUse: capturedLogicalContext }, handler, void 0, ...callbackArgs);\n\t\t\t}, timeout, ...args);\n\t\t}));\n\t}\n\tif (typeof globalThis.queueMicrotask !== \"undefined\" && !isHooked(globalThis.queueMicrotask)) {\n\t\tconst __queueMicrotask = globalThis.queueMicrotask;\n\t\tglobalThis.queueMicrotask = markAsHooked((callback) => {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __queueMicrotask(() => {\n\t\t\t\ttrampoline({ contextToUse: capturedLogicalContext }, callback, void 0);\n\t\t\t});\n\t\t});\n\t}\n\tconst __setImmediate = runtimeGlobal.setImmediate;\n\tif (typeof __setImmediate === \"function\" && !isHooked(__setImmediate)) runtimeGlobal.setImmediate = markAsHooked(((callback, ...args) => {\n\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\treturn __setImmediate((...callbackArgs) => {\n\t\t\ttrampoline({ contextToUse: capturedLogicalContext }, callback, void 0, ...callbackArgs);\n\t\t}, ...args);\n\t}));\n\tconst runtimeProcess = runtimeGlobal.process;\n\tif (runtimeProcess && typeof runtimeProcess.nextTick === \"function\" && !isHooked(runtimeProcess.nextTick)) {\n\t\tconst __nextTick = runtimeProcess.nextTick;\n\t\truntimeProcess.nextTick = markAsHooked((callback, ...args) => {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __nextTick(() => {\n\t\t\t\ttrampoline({ contextToUse: capturedLogicalContext }, callback, void 0, ...args);\n\t\t\t});\n\t\t});\n\t}\n\tif (typeof globalThis.requestAnimationFrame !== \"undefined\" && !isHooked(globalThis.requestAnimationFrame)) {\n\t\tconst __requestAnimationFrame = globalThis.requestAnimationFrame;\n\t\tglobalThis.requestAnimationFrame = markAsHooked((callback) => {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __requestAnimationFrame((time) => {\n\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, callback, void 0, time);\n\t\t\t});\n\t\t});\n\t}\n};\nvar prepare = () => {\n\tprepareRuntimeHooks();\n\tif (isPrepared) return;\n\tisPrepared = true;\n\tif (typeof Promise !== \"undefined\") {\n\t\tconst __then = Promise.prototype.then;\n\t\tconst __catch = Promise.prototype.catch;\n\t\tconst __finally = Promise.prototype.finally;\n\t\tPromise.prototype.then = function(onFulfilled, onRejected) {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __then.call(this, onFulfilled ? (value) => {\n\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, onFulfilled, void 0, value);\n\t\t\t} : void 0, onRejected ? (reason) => {\n\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, onRejected, void 0, reason);\n\t\t\t} : void 0);\n\t\t};\n\t\tPromise.prototype.catch = function(onRejected) {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __catch.call(this, onRejected ? (reason) => {\n\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, onRejected, void 0, reason);\n\t\t\t} : void 0);\n\t\t};\n\t\tPromise.prototype.finally = function(onFinally) {\n\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\treturn __finally.call(this, onFinally ? () => {\n\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, onFinally, void 0);\n\t\t\t} : void 0);\n\t\t};\n\t}\n\tif (typeof EventTarget !== \"undefined\" && EventTarget.prototype && EventTarget.prototype.addEventListener) {\n\t\tconst __eventTargetAddEventListener = EventTarget.prototype.addEventListener;\n\t\tEventTarget.prototype.addEventListener = function(type, listener, options) {\n\t\t\tif (listener === null || listener === void 0) return __eventTargetAddEventListener.call(this, type, listener, options);\n\t\t\tif (typeof listener === \"function\") {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t};\n\t\t\t\treturn __eventTargetAddEventListener.call(this, type, wrappedListener, options);\n\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\treturn __eventTargetAddEventListener.call(this, type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t}\n\t\t\treturn __eventTargetAddEventListener.call(this, type, listener, options);\n\t\t};\n\t}\n\tif (typeof Element !== \"undefined\" && Element.prototype && Element.prototype.addEventListener) {\n\t\tconst __elementAddEventListener = Element.prototype.addEventListener;\n\t\tElement.prototype.addEventListener = function(type, listener, options) {\n\t\t\tif (listener === null || listener === void 0) return __elementAddEventListener.call(this, type, listener, options);\n\t\t\tif (typeof listener === \"function\") {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t};\n\t\t\t\treturn __elementAddEventListener.call(this, type, wrappedListener, options);\n\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\treturn __elementAddEventListener.call(this, type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t}\n\t\t\treturn __elementAddEventListener.call(this, type, listener, options);\n\t\t};\n\t}\n\tif (typeof globalThis.XMLHttpRequest !== \"undefined\") {\n\t\tconst __XMLHttpRequest = globalThis.XMLHttpRequest;\n\t\tglobalThis.XMLHttpRequest = class extends __XMLHttpRequest {\n\t\t\tconstructor() {\n\t\t\t\tsuper();\n\t\t\t\tthis._userHandlers = /* @__PURE__ */ new Map();\n\t\t\t\t[\n\t\t\t\t\t\"onreadystatechange\",\n\t\t\t\t\t\"onloadstart\",\n\t\t\t\t\t\"onprogress\",\n\t\t\t\t\t\"onabort\",\n\t\t\t\t\t\"onerror\",\n\t\t\t\t\t\"onload\",\n\t\t\t\t\t\"ontimeout\",\n\t\t\t\t\t\"onloadend\"\n\t\t\t\t].forEach((prop) => {\n\t\t\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\t\t\tget: () => this._userHandlers.get(prop) || null,\n\t\t\t\t\t\tset: (newHandler) => {\n\t\t\t\t\t\t\tthis._userHandlers.set(prop, newHandler);\n\t\t\t\t\t\t\tif (newHandler && typeof newHandler === \"function\") {\n\t\t\t\t\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\t\t\t\t\tconst wrappedHandler = function(event) {\n\t\t\t\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, newHandler, this, event);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, wrappedHandler);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = wrappedHandler;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, null);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tenumerable: true\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\taddEventListener(type, listener, options) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tif (!listener) return super.addEventListener(type, listener, options);\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t\t};\n\t\t\t\t\treturn super.addEventListener(type, wrappedListener, options);\n\t\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) return super.addEventListener(type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t\treturn super.addEventListener(type, listener, options);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.WebSocket !== \"undefined\") {\n\t\tconst __WebSocket = globalThis.WebSocket;\n\t\tglobalThis.WebSocket = class extends __WebSocket {\n\t\t\tconstructor(url, protocols) {\n\t\t\t\tsuper(url, protocols);\n\t\t\t\tthis._userHandlers = /* @__PURE__ */ new Map();\n\t\t\t\t[\n\t\t\t\t\t\"onopen\",\n\t\t\t\t\t\"onmessage\",\n\t\t\t\t\t\"onerror\",\n\t\t\t\t\t\"onclose\"\n\t\t\t\t].forEach((prop) => {\n\t\t\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\t\t\tget: () => this._userHandlers.get(prop) || null,\n\t\t\t\t\t\tset: (newHandler) => {\n\t\t\t\t\t\t\tthis._userHandlers.set(prop, newHandler);\n\t\t\t\t\t\t\tif (newHandler && typeof newHandler === \"function\") {\n\t\t\t\t\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\t\t\t\t\tconst wrappedHandler = function(event) {\n\t\t\t\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, newHandler, this, event);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, wrappedHandler);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = wrappedHandler;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, null);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tenumerable: true\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\taddEventListener(type, listener, options) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tif (!listener) return super.addEventListener(type, listener, options);\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t\t};\n\t\t\t\t\treturn super.addEventListener(type, wrappedListener, options);\n\t\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) return super.addEventListener(type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t\treturn super.addEventListener(type, listener, options);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.MutationObserver !== \"undefined\") {\n\t\tconst __MutationObserver = globalThis.MutationObserver;\n\t\tglobalThis.MutationObserver = class extends __MutationObserver {\n\t\t\tconstructor(callback) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tconst wrappedCallback = (mutations, observer) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, callback, void 0, mutations, observer);\n\t\t\t\t};\n\t\t\t\tsuper(wrappedCallback);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.ResizeObserver !== \"undefined\") {\n\t\tconst __ResizeObserver = globalThis.ResizeObserver;\n\t\tglobalThis.ResizeObserver = class extends __ResizeObserver {\n\t\t\tconstructor(callback) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tconst wrappedCallback = (entries, observer) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, callback, void 0, entries, observer);\n\t\t\t\t};\n\t\t\t\tsuper(wrappedCallback);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.IntersectionObserver !== \"undefined\") {\n\t\tconst __IntersectionObserver = globalThis.IntersectionObserver;\n\t\tglobalThis.IntersectionObserver = class extends __IntersectionObserver {\n\t\t\tconstructor(callback, options) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tconst wrappedCallback = (entries, observer) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, callback, void 0, entries, observer);\n\t\t\t\t};\n\t\t\t\tsuper(wrappedCallback, options);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.Worker !== \"undefined\") {\n\t\tconst __Worker = globalThis.Worker;\n\t\tglobalThis.Worker = class extends __Worker {\n\t\t\tconstructor(scriptURL, options) {\n\t\t\t\tsuper(scriptURL, options);\n\t\t\t\tthis._userHandlers = /* @__PURE__ */ new Map();\n\t\t\t\t[\n\t\t\t\t\t\"onmessage\",\n\t\t\t\t\t\"onmessageerror\",\n\t\t\t\t\t\"onerror\"\n\t\t\t\t].forEach((prop) => {\n\t\t\t\t\tObject.defineProperty(this, prop, {\n\t\t\t\t\t\tget: () => this._userHandlers.get(prop) || null,\n\t\t\t\t\t\tset: (newHandler) => {\n\t\t\t\t\t\t\tthis._userHandlers.set(prop, newHandler);\n\t\t\t\t\t\t\tif (newHandler && typeof newHandler === \"function\") {\n\t\t\t\t\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\t\t\t\t\tconst wrappedHandler = function(event) {\n\t\t\t\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, newHandler, this, event);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, wrappedHandler);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = wrappedHandler;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(this)), prop);\n\t\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(this, null);\n\t\t\t\t\t\t\t\telse this[`_${prop}`] = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\tenumerable: true\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\taddEventListener(type, listener, options) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tif (!listener) return super.addEventListener(type, listener, options);\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t\t};\n\t\t\t\t\treturn super.addEventListener(type, wrappedListener, options);\n\t\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) return super.addEventListener(type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t\treturn super.addEventListener(type, listener, options);\n\t\t\t}\n\t\t};\n\t}\n\tif (typeof globalThis.MessagePort !== \"undefined\") {\n\t\tconst __MessagePort = globalThis.MessagePort;\n\t\tconst createMessagePortWrapper = (originalPort) => {\n\t\t\tconst _userHandlers = /* @__PURE__ */ new Map();\n\t\t\t[\"onmessage\", \"onmessageerror\"].forEach((prop) => {\n\t\t\t\tObject.defineProperty(originalPort, prop, {\n\t\t\t\t\tget: () => _userHandlers.get(prop) || null,\n\t\t\t\t\tset: (newHandler) => {\n\t\t\t\t\t\t_userHandlers.set(prop, newHandler);\n\t\t\t\t\t\tif (newHandler && typeof newHandler === \"function\") {\n\t\t\t\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\t\t\t\tconst wrappedHandler = function(event) {\n\t\t\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, newHandler, this, event);\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(originalPort, wrappedHandler);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n\t\t\t\t\t\t\tif (descriptor && descriptor.set) descriptor.set.call(originalPort, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: true\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst originalAddEventListener = originalPort.addEventListener;\n\t\t\toriginalPort.addEventListener = function(type, listener, options) {\n\t\t\t\tconst capturedLogicalContext = currentLogicalContext;\n\t\t\t\tif (!listener) return originalAddEventListener.call(this, type, listener, options);\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\tconst wrappedListener = (event) => {\n\t\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, listener, event.currentTarget, event);\n\t\t\t\t\t};\n\t\t\t\t\treturn originalAddEventListener.call(this, type, wrappedListener, options);\n\t\t\t\t} else if (typeof listener === \"object\" && \"handleEvent\" in listener) return originalAddEventListener.call(this, type, { handleEvent: (event) => {\n\t\t\t\t\treturn trampoline({ contextToUse: capturedLogicalContext }, () => listener.handleEvent(event));\n\t\t\t\t} }, options);\n\t\t\t\treturn originalAddEventListener.call(this, type, listener, options);\n\t\t\t};\n\t\t\treturn originalPort;\n\t\t};\n\t\tif (typeof globalThis.MessageChannel !== \"undefined\") {\n\t\t\tconst __MessageChannel = globalThis.MessageChannel;\n\t\t\tglobalThis.MessageChannel = class extends __MessageChannel {\n\t\t\t\tconstructor() {\n\t\t\t\t\tsuper();\n\t\t\t\t\tcreateMessagePortWrapper(this.port1);\n\t\t\t\t\tcreateMessagePortWrapper(this.port2);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n};\n//#endregion\n//#region src/primitives/logical-context.ts\n/**\n* Set a value in the current logical context\n* @param key The symbol key for the value\n* @param value The value to store\n*/\nvar setLogicalContextValue = (key, value) => {\n\tprepare();\n\tif (value !== void 0) currentLogicalContext.data.set(key, value);\n\telse currentLogicalContext.data.delete(key);\n};\n/**\n* Get a value from the current logical context\n* @param key The symbol key for the value\n* @returns The stored value or undefined if not found\n*/\nvar getLogicalContextValue = (key) => {\n\tprepare();\n\treturn currentLogicalContext.data.get(key);\n};\n/**\n* Run a handler on a new logical context\n* @param prefix The prefix for the new logical context\n* @param handler The handler to run\n* @returns The result of the handler\n*/\nvar runOnNewLogicalContext = (prefix, handler) => {\n\tconst previousLogicalContext = currentLogicalContext;\n\tsetCurrentLogicalContext(createLogicalContext(Symbol(`${prefix}-${crypto.randomUUID()}`)));\n\ttry {\n\t\treturn handler();\n\t} finally {\n\t\tsetCurrentLogicalContext(previousLogicalContext);\n\t}\n};\n/**\n* Get the current logical context id\n* @returns The current logical context id\n*/\nvar getCurrentLogicalContextId = () => {\n\tprepare();\n\treturn currentLogicalContext.id;\n};\n//#endregion\n//#region src/primitives/async-local.ts\n/**\n* Creates a new AsyncLocal instance\n* @template T The type of the value to store in the async context\n* @returns A new AsyncLocal instance\n*/\nvar createAsyncLocal = () => {\n\tconst key = Symbol(`async-local-${crypto.randomUUID()}`);\n\treturn {\n\t\tsetValue: (value) => {\n\t\t\tsetLogicalContextValue(key, value);\n\t\t},\n\t\tgetValue: () => {\n\t\t\treturn getLogicalContextValue(key);\n\t\t}\n\t};\n};\n//#endregion\n//#region src/primitives/semaphore.ts\nvar ABORTED_ERROR$1 = () => /* @__PURE__ */ new Error(\"Semaphore acquisition was aborted\");\nvar INVALID_COUNT_ERROR = () => /* @__PURE__ */ new Error(\"Semaphore count must be greater than 0\");\n/**\n* Creates a new SemaphoreHandle instance\n* @param releaseCallback Callback function to release the semaphore resource\n* @returns A SemaphoreHandle object with release and dispose functionality\n*/\nvar createSemaphoreHandle = (releaseCallback) => {\n\tlet isActive = true;\n\tconst release = () => {\n\t\tif (!isActive) return;\n\t\tisActive = false;\n\t\treleaseCallback();\n\t};\n\treturn {\n\t\tget isActive() {\n\t\t\treturn isActive;\n\t\t},\n\t\trelease,\n\t\t[Symbol.dispose]: release\n\t};\n};\n/**\n* Creates a new Semaphore instance for managing limited concurrent access\n* @param count The maximum number of concurrent acquisitions allowed (must be greater than 0)\n* @param maxConsecutiveCalls The maximum number of consecutive calls before yielding control\n* @returns A new Semaphore for managing concurrent resource access\n*/\nvar createSemaphore = (count, maxConsecutiveCalls = 20) => {\n\tif (count < 1) throw INVALID_COUNT_ERROR();\n\tlet availableCount = count;\n\tconst queue = [];\n\tlet consecutiveCallCount = 0;\n\tconst processQueue = () => {\n\t\twhile (availableCount > 0 && queue.length > 0) {\n\t\t\tvar _item$signal;\n\t\t\tconst item = queue.shift();\n\t\t\tif ((_item$signal = item.signal) === null || _item$signal === void 0 ? void 0 : _item$signal.aborted) {\n\t\t\t\titem.reject(ABORTED_ERROR$1());\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tavailableCount--;\n\t\t\tconst semaphoreHandle = createSemaphoreHandle(releaseSemaphore);\n\t\t\titem.resolve(semaphoreHandle);\n\t\t}\n\t};\n\tconst scheduleNextProcess = () => {\n\t\tconsecutiveCallCount++;\n\t\tif (consecutiveCallCount >= maxConsecutiveCalls) {\n\t\t\tconsecutiveCallCount = 0;\n\t\t\tdefer(processQueue);\n\t\t} else processQueue();\n\t};\n\tconst releaseSemaphore = () => {\n\t\tavailableCount++;\n\t\tscheduleNextProcess();\n\t};\n\tconst removeFromQueue = (item) => {\n\t\tconst index = queue.indexOf(item);\n\t\tif (index !== -1) queue.splice(index, 1);\n\t};\n\tconst acquire = async (signal) => {\n\t\tif (signal) {\n\t\t\tif (signal.aborted) throw ABORTED_ERROR$1();\n\t\t\tif (availableCount > 0) {\n\t\t\t\tavailableCount--;\n\t\t\t\treturn createSemaphoreHandle(releaseSemaphore);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst queueItem = {\n\t\t\t\t\tresolve: void 0,\n\t\t\t\t\treject: void 0,\n\t\t\t\t\tsignal\n\t\t\t\t};\n\t\t\t\tconst abortHandle = onAbort(signal, () => {\n\t\t\t\t\tremoveFromQueue(queueItem);\n\t\t\t\t\treject(ABORTED_ERROR$1());\n\t\t\t\t});\n\t\t\t\tqueueItem.resolve = (handle) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\tresolve(handle);\n\t\t\t\t};\n\t\t\t\tqueueItem.reject = (error) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\treject(error);\n\t\t\t\t};\n\t\t\t\tqueue.push(queueItem);\n\t\t\t\tprocessQueue();\n\t\t\t});\n\t\t} else {\n\t\t\tif (availableCount > 0) {\n\t\t\t\tavailableCount--;\n\t\t\t\treturn createSemaphoreHandle(releaseSemaphore);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tqueue.push({\n\t\t\t\t\tresolve,\n\t\t\t\t\treject\n\t\t\t\t});\n\t\t\t\tprocessQueue();\n\t\t\t});\n\t\t}\n\t};\n\treturn {\n\t\tacquire,\n\t\twaiter: { wait: acquire },\n\t\tget availableCount() {\n\t\t\treturn availableCount;\n\t\t},\n\t\tget pendingCount() {\n\t\t\treturn queue.length;\n\t\t}\n\t};\n};\n//#endregion\n//#region src/primitives/reader-writer-lock.ts\nvar ABORTED_ERROR = () => /* @__PURE__ */ new Error(\"Lock acquisition was aborted\");\n/**\n* Creates a new ReadLockHandle instance\n* @param releaseCallback Callback function to release the read lock\n* @returns A ReadLockHandle object with release and dispose functionality\n*/\nvar createReadLockHandle = (releaseCallback) => {\n\tlet isActive = true;\n\tconst release = () => {\n\t\tif (!isActive) return;\n\t\tisActive = false;\n\t\treleaseCallback();\n\t};\n\treturn {\n\t\tget isActive() {\n\t\t\treturn isActive;\n\t\t},\n\t\trelease,\n\t\t[Symbol.dispose]: release\n\t};\n};\n/**\n* Creates a new WriteLockHandle instance\n* @param releaseCallback Callback function to release the write lock\n* @returns A WriteLockHandle object with release and dispose functionality\n*/\nvar createWriteLockHandle = (releaseCallback) => {\n\tlet isActive = true;\n\tconst release = () => {\n\t\tif (!isActive) return;\n\t\tisActive = false;\n\t\treleaseCallback();\n\t};\n\treturn {\n\t\tget isActive() {\n\t\t\treturn isActive;\n\t\t},\n\t\trelease,\n\t\t[Symbol.dispose]: release\n\t};\n};\nfunction createReaderWriterLock(optionsOrMaxCalls) {\n\tlet policy = \"write-preferring\";\n\tlet maxConsecutiveCalls = 20;\n\tif (typeof optionsOrMaxCalls === \"number\") maxConsecutiveCalls = optionsOrMaxCalls;\n\telse if (optionsOrMaxCalls) {\n\t\tvar _optionsOrMaxCalls$po, _optionsOrMaxCalls$ma;\n\t\tpolicy = (_optionsOrMaxCalls$po = optionsOrMaxCalls.policy) !== null && _optionsOrMaxCalls$po !== void 0 ? _optionsOrMaxCalls$po : \"write-preferring\";\n\t\tmaxConsecutiveCalls = (_optionsOrMaxCalls$ma = optionsOrMaxCalls.maxConsecutiveCalls) !== null && _optionsOrMaxCalls$ma !== void 0 ? _optionsOrMaxCalls$ma : 20;\n\t}\n\tlet currentReaders = 0;\n\tlet hasWriter = false;\n\tconst readQueue = [];\n\tconst writeQueue = [];\n\tlet consecutiveCallCount = 0;\n\tconst processQueues = () => {\n\t\tif (policy === \"write-preferring\") {\n\t\t\tif (!hasWriter && currentReaders === 0 && writeQueue.length > 0) {\n\t\t\t\tvar _item$signal;\n\t\t\t\tconst item = writeQueue.shift();\n\t\t\t\tif ((_item$signal = item.signal) === null || _item$signal === void 0 ? void 0 : _item$signal.aborted) {\n\t\t\t\t\titem.reject(ABORTED_ERROR());\n\t\t\t\t\tscheduleNextProcess();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\thasWriter = true;\n\t\t\t\tconst writeLockHandle = createWriteLockHandle(releaseWriteLock);\n\t\t\t\titem.resolve(writeLockHandle);\n\t\t\t} else if (!hasWriter && writeQueue.length === 0 && readQueue.length > 0) {\n\t\t\t\tconst readersToProcess = [];\n\t\t\t\twhile (readQueue.length > 0) {\n\t\t\t\t\tvar _item$signal2;\n\t\t\t\t\tconst item = readQueue.shift();\n\t\t\t\t\tif ((_item$signal2 = item.signal) === null || _item$signal2 === void 0 ? void 0 : _item$signal2.aborted) item.reject(ABORTED_ERROR());\n\t\t\t\t\telse readersToProcess.push(item);\n\t\t\t\t}\n\t\t\t\tfor (const item of readersToProcess) {\n\t\t\t\t\tcurrentReaders++;\n\t\t\t\t\tconst readLockHandle = createReadLockHandle(releaseReadLock);\n\t\t\t\t\titem.resolve(readLockHandle);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!hasWriter && readQueue.length > 0) {\n\t\t\tconst readersToProcess = [];\n\t\t\twhile (readQueue.length > 0) {\n\t\t\t\tvar _item$signal3;\n\t\t\t\tconst item = readQueue.shift();\n\t\t\t\tif ((_item$signal3 = item.signal) === null || _item$signal3 === void 0 ? void 0 : _item$signal3.aborted) item.reject(ABORTED_ERROR());\n\t\t\t\telse readersToProcess.push(item);\n\t\t\t}\n\t\t\tfor (const item of readersToProcess) {\n\t\t\t\tcurrentReaders++;\n\t\t\t\tconst readLockHandle = createReadLockHandle(releaseReadLock);\n\t\t\t\titem.resolve(readLockHandle);\n\t\t\t}\n\t\t} else if (!hasWriter && currentReaders === 0 && writeQueue.length > 0) {\n\t\t\tvar _item$signal4;\n\t\t\tconst item = writeQueue.shift();\n\t\t\tif ((_item$signal4 = item.signal) === null || _item$signal4 === void 0 ? void 0 : _item$signal4.aborted) {\n\t\t\t\titem.reject(ABORTED_ERROR());\n\t\t\t\tscheduleNextProcess();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thasWriter = true;\n\t\t\tconst writeLockHandle = createWriteLockHandle(releaseWriteLock);\n\t\t\titem.resolve(writeLockHandle);\n\t\t}\n\t};\n\tconst scheduleNextProcess = () => {\n\t\tconsecutiveCallCount++;\n\t\tif (consecutiveCallCount >= maxConsecutiveCalls) {\n\t\t\tconsecutiveCallCount = 0;\n\t\t\tdefer(processQueues);\n\t\t} else processQueues();\n\t};\n\tconst releaseReadLock = () => {\n\t\tif (currentReaders > 0) {\n\t\t\tcurrentReaders--;\n\t\t\tif (currentReaders === 0) scheduleNextProcess();\n\t\t}\n\t};\n\tconst releaseWriteLock = () => {\n\t\tif (hasWriter) {\n\t\t\thasWriter = false;\n\t\t\tscheduleNextProcess();\n\t\t}\n\t};\n\tconst removeFromReadQueue = (item) => {\n\t\tconst index = readQueue.indexOf(item);\n\t\tif (index !== -1) readQueue.splice(index, 1);\n\t};\n\tconst removeFromWriteQueue = (item) => {\n\t\tconst index = writeQueue.indexOf(item);\n\t\tif (index !== -1) writeQueue.splice(index, 1);\n\t};\n\tconst readLock = async (signal) => {\n\t\tif (signal) {\n\t\t\tif (signal.aborted) throw ABORTED_ERROR();\n\t\t\tif (policy === \"read-preferring\" ? !hasWriter : !hasWriter && writeQueue.length === 0) {\n\t\t\t\tcurrentReaders++;\n\t\t\t\treturn createReadLockHandle(releaseReadLock);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst queueItem = {\n\t\t\t\t\tresolve: void 0,\n\t\t\t\t\treject: void 0,\n\t\t\t\t\tsignal\n\t\t\t\t};\n\t\t\t\tconst abortHandle = onAbort(signal, () => {\n\t\t\t\t\tremoveFromReadQueue(queueItem);\n\t\t\t\t\treject(ABORTED_ERROR());\n\t\t\t\t});\n\t\t\t\tqueueItem.resolve = (handle) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\tresolve(handle);\n\t\t\t\t};\n\t\t\t\tqueueItem.reject = (error) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\treject(error);\n\t\t\t\t};\n\t\t\t\treadQueue.push(queueItem);\n\t\t\t\tprocessQueues();\n\t\t\t});\n\t\t} else {\n\t\t\tif (policy === \"read-preferring\" ? !hasWriter : !hasWriter && writeQueue.length === 0) {\n\t\t\t\tcurrentReaders++;\n\t\t\t\treturn createReadLockHandle(releaseReadLock);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\treadQueue.push({\n\t\t\t\t\tresolve,\n\t\t\t\t\treject\n\t\t\t\t});\n\t\t\t\tprocessQueues();\n\t\t\t});\n\t\t}\n\t};\n\tconst writeLock = async (signal) => {\n\t\tif (signal) {\n\t\t\tif (signal.aborted) throw ABORTED_ERROR();\n\t\t\tif (!hasWriter && currentReaders === 0) {\n\t\t\t\thasWriter = true;\n\t\t\t\treturn createWriteLockHandle(releaseWriteLock);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst queueItem = {\n\t\t\t\t\tresolve: void 0,\n\t\t\t\t\treject: void 0,\n\t\t\t\t\tsignal\n\t\t\t\t};\n\t\t\t\tconst abortHandle = onAbort(signal, () => {\n\t\t\t\t\tremoveFromWriteQueue(queueItem);\n\t\t\t\t\treject(ABORTED_ERROR());\n\t\t\t\t});\n\t\t\t\tqueueItem.resolve = (handle) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\tresolve(handle);\n\t\t\t\t};\n\t\t\t\tqueueItem.reject = (error) => {\n\t\t\t\t\tabortHandle.release();\n\t\t\t\t\treject(error);\n\t\t\t\t};\n\t\t\t\twriteQueue.push(queueItem);\n\t\t\t\tprocessQueues();\n\t\t\t});\n\t\t} else {\n\t\t\tif (!hasWriter && currentReaders === 0) {\n\t\t\t\thasWriter = true;\n\t\t\t\treturn createWriteLockHandle(releaseWriteLock);\n\t\t\t}\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\twriteQueue.push({\n\t\t\t\t\tresolve,\n\t\t\t\t\treject\n\t\t\t\t});\n\t\t\t\tprocessQueues();\n\t\t\t});\n\t\t}\n\t};\n\treturn {\n\t\treadLock,\n\t\twriteLock,\n\t\treadWaiter: { wait: readLock },\n\t\twriteWaiter: { wait: writeLock },\n\t\tget currentReaders() {\n\t\t\treturn currentReaders;\n\t\t},\n\t\tget hasWriter() {\n\t\t\treturn hasWriter;\n\t\t},\n\t\tget pendingReadersCount() {\n\t\t\treturn readQueue.length;\n\t\t},\n\t\tget pendingWritersCount() {\n\t\t\treturn writeQueue.length;\n\t\t}\n\t};\n}\n//#endregion\n//#region src/primitives/async-operator.ts\nvar __NO_INITIAL_VALUE = Symbol(\"no-initial-value\");\nvar __LINEAR_SKIP = Symbol(\"linear-skip\");\nvar __LINEAR_STOP = Symbol(\"linear-stop\");\nvar createAsyncIterable = (iteratorFactory) => ({ [Symbol.asyncIterator]: iteratorFactory });\nvar createSyncIterable = (iteratorFactory) => ({ [Symbol.iterator]: iteratorFactory });\nvar createIteratorFactories = (source) => isAsyncIterable(source) ? {\n\tsyncFactory: void 0,\n\tasyncFactory: () => toAsyncIterable(source)\n} : {\n\tsyncFactory: () => source,\n\tasyncFactory: () => toAsyncIterable(source)\n};\nvar createAsyncOnlyFactories = (asyncFactory) => ({\n\tsyncFactory: void 0,\n\tasyncFactory\n});\nvar normalizeIteratorFactories = (iteratorFactoriesOrAsyncFactory) => typeof iteratorFactoriesOrAsyncFactory === \"function\" ? createAsyncOnlyFactories(iteratorFactoriesOrAsyncFactory) : iteratorFactoriesOrAsyncFactory;\nvar identity = (value) => value;\nvar sameValueZero = (left, right) => left === right || left !== left && right !== right;\nvar isArraySource = (source) => Array.isArray(source);\nvar isPromiseLike = (value) => (typeof value === \"object\" && value !== null || typeof value === \"function\") && typeof value.then === \"function\";\nvar isAsyncIterable = (source) => typeof source[Symbol.asyncIterator] === \"function\";\nvar toAsyncIterable = (source) => createAsyncIterable(async function* () {\n\tif (isAsyncIterable(source)) for await (const value of source) yield value;\n\telse for (const value of source) yield isPromiseLike(value) ? await value : value;\n});\nvar toIntegerOrInfinity = (value) => {\n\tif (Number.isNaN(value) || value === 0) return 0;\n\tif (!Number.isFinite(value)) return value;\n\treturn Math.trunc(value);\n};\nvar normalizeCount = (count) => {\n\tif (Number.isNaN(count) || count <= 0) return 0;\n\treturn Math.trunc(count);\n};\nvar normalizeRequiredCount = (count, name) => {\n\tif (!Number.isFinite(count) || count <= 0) throw new RangeError(`${name} must be greater than 0`);\n\treturn Math.trunc(count);\n};\nvar isNonNullish = (value) => value !== null && value !== void 0;\nvar compareValues = (left, right) => {\n\tif (left < right) return -1;\n\tif (left > right) return 1;\n\treturn 0;\n};\nvar createLinearRuntimeState = (operation) => {\n\tswitch (operation.kind) {\n\t\tcase \"map\":\n\t\tcase \"filter\":\n\t\tcase \"choose\":\n\t\tcase \"takeWhile\": return {\n\t\t\tkind: operation.kind,\n\t\t\tindex: 0\n\t\t};\n\t\tcase \"skipWhile\": return {\n\t\t\tkind: operation.kind,\n\t\t\tindex: 0,\n\t\t\tskipping: true\n\t\t};\n\t}\n};\nvar createLinearPipelineFactories = (pipeline) => createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\tconst runtimeStates = pipeline.operations.map(createLinearRuntimeState);\n\tconst applyOperations = async (input) => {\n\t\tlet current = input;\n\t\tfor (let operationIndex = 0; operationIndex < pipeline.operations.length; operationIndex++) {\n\t\t\tconst operation = pipeline.operations[operationIndex];\n\t\t\tconst runtimeState = runtimeStates[operationIndex];\n\t\t\tswitch (operation.kind) {\n\t\t\t\tcase \"map\": {\n\t\t\t\t\tconst selected = operation.selector(current, runtimeState.index);\n\t\t\t\t\tcurrent = isPromiseLike(selected) ? await selected : selected;\n\t\t\t\t\truntimeState.index++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"filter\": {\n\t\t\t\t\tconst result = operation.predicate(current, runtimeState.index);\n\t\t\t\t\tconst included = isPromiseLike(result) ? await result : result;\n\t\t\t\t\truntimeState.index++;\n\t\t\t\t\tif (!included) return __LINEAR_SKIP;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"choose\": {\n\t\t\t\t\tconst result = operation.selector(current, runtimeState.index);\n\t\t\t\t\tconst selected = isPromiseLike(result) ? await result : result;\n\t\t\t\t\truntimeState.index++;\n\t\t\t\t\tif (!isNonNullish(selected)) return __LINEAR_SKIP;\n\t\t\t\t\tcurrent = selected;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"skipWhile\": {\n\t\t\t\t\tconst skipState = runtimeState;\n\t\t\t\t\tconst result = operation.predicate(current, runtimeState.index);\n\t\t\t\t\tconst shouldSkip = isPromiseLike(result) ? await result : result;\n\t\t\t\t\truntimeState.index++;\n\t\t\t\t\tif (skipState.skipping && shouldSkip) return __LINEAR_SKIP;\n\t\t\t\t\tskipState.skipping = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"takeWhile\": {\n\t\t\t\t\tconst result = operation.predicate(current, runtimeState.index);\n\t\t\t\t\tif (!(isPromiseLike(result) ? await result : result)) return __LINEAR_STOP;\n\t\t\t\t\truntimeState.index++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn current;\n\t};\n\tconst { syncFactory, asyncFactory } = pipeline.sourceFactories;\n\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\tconst processedValue = await applyOperations(isPromiseLike(value) ? await value : value);\n\t\tif (processedValue === __LINEAR_STOP) return;\n\t\tif (processedValue !== __LINEAR_SKIP) yield processedValue;\n\t}\n\telse for await (const value of asyncFactory()) {\n\t\tconst processedValue = await applyOperations(value);\n\t\tif (processedValue === __LINEAR_STOP) return;\n\t\tif (processedValue !== __LINEAR_SKIP) yield processedValue;\n\t}\n}));\nvar collectKeysFromSource = async (source, selector) => {\n\tconst { syncFactory, asyncFactory } = createIteratorFactories(source);\n\tlet index = 0;\n\tconst keys = /* @__PURE__ */ new Set();\n\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\tconst key = selector(isPromiseLike(value) ? await value : value, index);\n\t\tkeys.add(isPromiseLike(key) ? await key : key);\n\t\tindex++;\n\t}\n\telse for await (const value of asyncFactory()) {\n\t\tconst key = selector(value, index);\n\t\tkeys.add(isPromiseLike(key) ? await key : key);\n\t\tindex++;\n\t}\n\treturn keys;\n};\nvar collectValuesFromSource = async (source) => {\n\tconst { syncFactory, asyncFactory } = createIteratorFactories(source);\n\tconst values = /* @__PURE__ */ new Set();\n\tif (syncFactory !== void 0) for (const value of syncFactory()) values.add(isPromiseLike(value) ? await value : value);\n\telse for await (const value of asyncFactory()) values.add(value);\n\treturn values;\n};\nvar materializeValues = async (iteratorFactories) => {\n\tconst { syncFactory, asyncFactory } = iteratorFactories;\n\tconst values = [];\n\tif (syncFactory !== void 0) for (const value of syncFactory()) values.push(isPromiseLike(value) ? await value : value);\n\telse for await (const value of asyncFactory()) values.push(value);\n\treturn values;\n};\nvar findExtremeBy = async (iteratorFactories, selector, direction) => {\n\tconst { syncFactory, asyncFactory } = iteratorFactories;\n\tlet index = 0;\n\tlet hasBestValue = false;\n\tlet bestValue;\n\tlet bestKey;\n\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\tconst selectedKey = selector(resolvedValue, index);\n\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\tif (!hasBestValue || (direction === \"min\" ? compareValues(key, bestKey) < 0 : compareValues(key, bestKey) > 0)) {\n\t\t\thasBestValue = true;\n\t\t\tbestValue = resolvedValue;\n\t\t\tbestKey = key;\n\t\t}\n\t\tindex++;\n\t}\n\telse for await (const value of asyncFactory()) {\n\t\tconst selectedKey = selector(value, index);\n\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\tif (!hasBestValue || (direction === \"min\" ? compareValues(key, bestKey) < 0 : compareValues(key, bestKey) > 0)) {\n\t\t\thasBestValue = true;\n\t\t\tbestValue = value;\n\t\t\tbestKey = key;\n\t\t}\n\t\tindex++;\n\t}\n\treturn bestValue;\n};\nvar createAsyncOperator = (iteratorFactoriesOrAsyncFactory, linearPipeline) => {\n\tconst iteratorFactories = normalizeIteratorFactories(iteratorFactoriesOrAsyncFactory);\n\tconst { syncFactory, asyncFactory } = iteratorFactories;\n\tconst iterableFactory = asyncFactory;\n\tconst appendLinearOperation = (operation, createFallbackIteratorFactories) => {\n\t\tconst nextLinearPipeline = linearPipeline === void 0 ? {\n\t\t\tsourceFactories: iteratorFactories,\n\t\t\toperations: [operation]\n\t\t} : {\n\t\t\tsourceFactories: linearPipeline.sourceFactories,\n\t\t\toperations: [...linearPipeline.operations, operation]\n\t\t};\n\t\treturn createAsyncOperator(linearPipeline === void 0 ? createFallbackIteratorFactories() : createLinearPipelineFactories(nextLinearPipeline), nextLinearPipeline);\n\t};\n\tconst reduce = (async (...args) => {\n\t\tconst [reducer] = args;\n\t\tlet accumulator = args.length === 2 ? args[1] : __NO_INITIAL_VALUE;\n\t\tlet index = 0;\n\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\tif (accumulator === __NO_INITIAL_VALUE) accumulator = resolvedValue;\n\t\t\telse {\n\t\t\t\tconst reduced = reducer(accumulator, resolvedValue, index);\n\t\t\t\taccumulator = isPromiseLike(reduced) ? await reduced : reduced;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\telse for await (const value of asyncFactory()) {\n\t\t\tif (accumulator === __NO_INITIAL_VALUE) accumulator = value;\n\t\t\telse {\n\t\t\t\tconst reduced = reducer(accumulator, value, index);\n\t\t\t\taccumulator = isPromiseLike(reduced) ? await reduced : reduced;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t\tif (accumulator === __NO_INITIAL_VALUE) throw new TypeError(\"Reduce of empty AsyncOperator with no initial value\");\n\t\treturn accumulator;\n\t});\n\tconst reduceRight = (async (...args) => {\n\t\tconst [reducer] = args;\n\t\tconst hasInitialValue = args.length === 2;\n\t\tconst values = await materializeValues(iteratorFactories);\n\t\tlet accumulator = hasInitialValue ? args[1] : __NO_INITIAL_VALUE;\n\t\tfor (let index = values.length - 1; index >= 0; index--) {\n\t\t\tconst value = values[index];\n\t\t\tif (accumulator === __NO_INITIAL_VALUE) accumulator = value;\n\t\t\telse {\n\t\t\t\tconst reduced = reducer(accumulator, value, index);\n\t\t\t\taccumulator = isPromiseLike(reduced) ? await reduced : reduced;\n\t\t\t}\n\t\t}\n\t\tif (accumulator === __NO_INITIAL_VALUE) throw new TypeError(\"ReduceRight of empty AsyncOperator with no initial value\");\n\t\treturn accumulator;\n\t});\n\tconst flat = ((depth) => createAsyncOperator(createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\tconst values = await materializeValues(iteratorFactories);\n\t\tfor (const value of values.flat(depth)) yield value;\n\t}))));\n\treturn {\n\t\t[Symbol.asyncIterator]: () => asyncFactory()[Symbol.asyncIterator](),\n\t\tmap: (selector) => appendLinearOperation({\n\t\t\tkind: \"map\",\n\t\t\tselector\n\t\t}, () => {\n\t\t\tconst mappedSyncFactory = syncFactory === void 0 ? void 0 : () => createSyncIterable(function* () {\n\t\t\t\tlet index = 0;\n\t\t\t\tfor (const value of syncFactory()) {\n\t\t\t\t\tconst currentIndex = index;\n\t\t\t\t\tif (isPromiseLike(value)) yield value.then((resolvedValue) => selector(resolvedValue, currentIndex));\n\t\t\t\t\telse yield selector(value, currentIndex);\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (mappedSyncFactory !== void 0) return {\n\t\t\t\tsyncFactory: mappedSyncFactory,\n\t\t\t\tasyncFactory: () => toAsyncIterable(mappedSyncFactory())\n\t\t\t};\n\t\t\treturn createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\t\tlet index = 0;\n\t\t\t\tfor await (const value of iterableFactory()) {\n\t\t\t\t\tconst selected = selector(value, index);\n\t\t\t\t\tyield isPromiseLike(selected) ? await selected : selected;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t}));\n\t\t}),\n\t\tflatMap: (selector) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) {\n\t\t\t\tconst source = syncFactory();\n\t\t\t\tif (Array.isArray(source)) for (let outerIndex = 0; outerIndex < source.length; outerIndex++) {\n\t\t\t\t\tconst value = source[outerIndex];\n\t\t\t\t\tconst selected = selector(isPromiseLike(value) ? await value : value, index);\n\t\t\t\t\tconst innerSource = isPromiseLike(selected) ? await selected : selected;\n\t\t\t\t\tif (isArraySource(innerSource)) for (let innerIndex = 0; innerIndex < innerSource.length; innerIndex++) {\n\t\t\t\t\t\tconst innerValue = innerSource[innerIndex];\n\t\t\t\t\t\tyield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\t\t}\n\t\t\t\t\telse if (isAsyncIterable(innerSource)) for await (const innerValue of innerSource) yield innerValue;\n\t\t\t\t\telse for (const innerValue of innerSource) yield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\telse for (const value of source) {\n\t\t\t\t\tconst selected = selector(isPromiseLike(value) ? await value : value, index);\n\t\t\t\t\tconst innerSource = isPromiseLike(selected) ? await selected : selected;\n\t\t\t\t\tif (isArraySource(innerSource)) for (let innerIndex = 0; innerIndex < innerSource.length; innerIndex++) {\n\t\t\t\t\t\tconst innerValue = innerSource[innerIndex];\n\t\t\t\t\t\tyield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\t\t}\n\t\t\t\t\telse if (isAsyncIterable(innerSource)) for await (const innerValue of innerSource) yield innerValue;\n\t\t\t\t\telse for (const innerValue of innerSource) yield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t} else for await (const value of iterableFactory()) {\n\t\t\t\tconst selected = selector(value, index);\n\t\t\t\tconst innerSource = isPromiseLike(selected) ? await selected : selected;\n\t\t\t\tif (isArraySource(innerSource)) for (let innerIndex = 0; innerIndex < innerSource.length; innerIndex++) {\n\t\t\t\t\tconst innerValue = innerSource[innerIndex];\n\t\t\t\t\tyield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\t}\n\t\t\t\telse if (isAsyncIterable(innerSource)) for await (const innerValue of innerSource) yield innerValue;\n\t\t\t\telse for (const innerValue of innerSource) yield isPromiseLike(innerValue) ? await innerValue : innerValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\tfilter: (predicate) => appendLinearOperation({\n\t\t\tkind: \"filter\",\n\t\t\tpredicate\n\t\t}, () => createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst result = predicate(resolvedValue, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) yield resolvedValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) yield value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}))),\n\t\tconcat: (...sources) => {\n\t\t\tconst concatenatedSyncFactory = syncFactory !== void 0 && sources.every((source) => !isAsyncIterable(source)) ? () => createSyncIterable(function* () {\n\t\t\t\tfor (const value of syncFactory()) yield value;\n\t\t\t\tfor (const source of sources) for (const value of source) yield value;\n\t\t\t}) : void 0;\n\t\t\tif (concatenatedSyncFactory !== void 0) return createAsyncOperator({\n\t\t\t\tsyncFactory: concatenatedSyncFactory,\n\t\t\t\tasyncFactory: () => toAsyncIterable(concatenatedSyncFactory())\n\t\t\t});\n\t\t\treturn createAsyncOperator(createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) yield isPromiseLike(value) ? await value : value;\n\t\t\t\telse for await (const value of iterableFactory()) yield value;\n\t\t\t\tfor (const source of sources) if (isAsyncIterable(source)) for await (const value of source) yield value;\n\t\t\t\telse for (const value of source) yield isPromiseLike(value) ? await value : value;\n\t\t\t})));\n\t\t},\n\t\tchoose: (selector) => appendLinearOperation({\n\t\t\tkind: \"choose\",\n\t\t\tselector\n\t\t}, () => createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = selector(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tconst selected = isPromiseLike(result) ? await result : result;\n\t\t\t\tif (isNonNullish(selected)) yield selected;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = selector(value, index);\n\t\t\t\tconst selected = isPromiseLike(result) ? await result : result;\n\t\t\t\tif (isNonNullish(selected)) yield selected;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}))),\n\t\tslice: (start, end) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst normalizedStart = toIntegerOrInfinity(start);\n\t\t\tconst normalizedEnd = end === void 0 ? void 0 : toIntegerOrInfinity(end);\n\t\t\tif (normalizedStart < 0 || normalizedEnd !== void 0 && normalizedEnd < 0) {\n\t\t\t\tconst values = await materializeValues(iteratorFactories);\n\t\t\t\tfor (const value of values.slice(start, end)) yield value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst startIndex = Math.max(normalizedStart, 0);\n\t\t\tif (startIndex === Infinity) return;\n\t\t\tconst endIndex = normalizedEnd === void 0 ? void 0 : Math.max(normalizedEnd, 0);\n\t\t\tif (endIndex !== void 0 && endIndex !== Infinity && endIndex <= startIndex) return;\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) {\n\t\t\t\tconst iterator = syncFactory()[Symbol.iterator]();\n\t\t\t\twhile (true) {\n\t\t\t\t\tif (endIndex !== void 0 && endIndex !== Infinity && index >= endIndex) return;\n\t\t\t\t\tconst result = iterator.next();\n\t\t\t\t\tif (result.done) return;\n\t\t\t\t\tconst value = result.value;\n\t\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\t\tif (index >= startIndex) yield resolvedValue;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst iterator = iterableFactory()[Symbol.asyncIterator]();\n\t\t\t\twhile (true) {\n\t\t\t\t\tif (endIndex !== void 0 && endIndex !== Infinity && index >= endIndex) return;\n\t\t\t\t\tconst result = await iterator.next();\n\t\t\t\t\tif (result.done) return;\n\t\t\t\t\tconst value = result.value;\n\t\t\t\t\tif (index >= startIndex) yield value;\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t}\n\t\t})),\n\t\tdistinct: () => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst seenValues = /* @__PURE__ */ new Set();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (!seenValues.has(resolvedValue)) {\n\t\t\t\t\tseenValues.add(resolvedValue);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) if (!seenValues.has(value)) {\n\t\t\t\tseenValues.add(value);\n\t\t\t\tyield value;\n\t\t\t}\n\t\t})),\n\t\tdistinctBy: (selector) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tconst seenKeys = /* @__PURE__ */ new Set();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\tskip: (count) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst normalizedCount = normalizeCount(count);\n\t\t\tlet skippedCount = 0;\n\t\t\tfor await (const value of iterableFactory()) {\n\t\t\t\tif (skippedCount < normalizedCount) {\n\t\t\t\t\tskippedCount++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tyield value;\n\t\t\t}\n\t\t})),\n\t\tskipWhile: (predicate) => appendLinearOperation({\n\t\t\tkind: \"skipWhile\",\n\t\t\tpredicate\n\t\t}, () => createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tlet skipping = true;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst result = predicate(resolvedValue, index);\n\t\t\t\tif (skipping && (isPromiseLike(result) ? await result : result)) {\n\t\t\t\t\tindex++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tskipping = false;\n\t\t\t\tyield resolvedValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (skipping && (isPromiseLike(result) ? await result : result)) {\n\t\t\t\t\tindex++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tskipping = false;\n\t\t\t\tyield value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}))),\n\t\ttake: (count) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst normalizedCount = normalizeCount(count);\n\t\t\tif (normalizedCount === 0) return;\n\t\t\tlet takenCount = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tyield isPromiseLike(value) ? await value : value;\n\t\t\t\ttakenCount++;\n\t\t\t\tif (takenCount >= normalizedCount) return;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tyield value;\n\t\t\t\ttakenCount++;\n\t\t\t\tif (takenCount >= normalizedCount) return;\n\t\t\t}\n\t\t})),\n\t\ttakeWhile: (predicate) => appendLinearOperation({\n\t\t\tkind: \"takeWhile\",\n\t\t\tpredicate\n\t\t}, () => createAsyncOnlyFactories(() => createAsyncIterable(async function* () {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst result = predicate(resolvedValue, index);\n\t\t\t\tif (!(isPromiseLike(result) ? await result : result)) return;\n\t\t\t\tyield resolvedValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (!(isPromiseLike(result) ? await result : result)) return;\n\t\t\t\tyield value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}))),\n\t\tpairwise: () => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tlet hasPreviousValue = false;\n\t\t\tlet previousValue;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (hasPreviousValue) yield [previousValue, resolvedValue];\n\t\t\t\tpreviousValue = resolvedValue;\n\t\t\t\thasPreviousValue = true;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tif (hasPreviousValue) yield [previousValue, value];\n\t\t\t\tpreviousValue = value;\n\t\t\t\thasPreviousValue = true;\n\t\t\t}\n\t\t})),\n\t\tzip: (source) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tif (isAsyncIterable(source)) {\n\t\t\t\tconst otherIterator = source[Symbol.asyncIterator]();\n\t\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\t\tconst otherResult = await otherIterator.next();\n\t\t\t\t\tif (otherResult.done) return;\n\t\t\t\t\tyield [isPromiseLike(value) ? await value : value, otherResult.value];\n\t\t\t\t}\n\t\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\t\tconst otherResult = await otherIterator.next();\n\t\t\t\t\tif (otherResult.done) return;\n\t\t\t\t\tyield [value, otherResult.value];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst otherIterator = source[Symbol.iterator]();\n\t\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\t\tconst otherResult = otherIterator.next();\n\t\t\t\t\tif (otherResult.done) return;\n\t\t\t\t\tyield [isPromiseLike(value) ? await value : value, isPromiseLike(otherResult.value) ? await otherResult.value : otherResult.value];\n\t\t\t\t}\n\t\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\t\tconst otherResult = otherIterator.next();\n\t\t\t\t\tif (otherResult.done) return;\n\t\t\t\t\tyield [value, isPromiseLike(otherResult.value) ? await otherResult.value : otherResult.value];\n\t\t\t\t}\n\t\t\t}\n\t\t})),\n\t\tscan: (reducer, initialValue) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tlet accumulator = initialValue;\n\t\t\tlet index = 0;\n\t\t\tyield accumulator;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst reduced = reducer(accumulator, resolvedValue, index);\n\t\t\t\taccumulator = isPromiseLike(reduced) ? await reduced : reduced;\n\t\t\t\tyield accumulator;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst reduced = reducer(accumulator, value, index);\n\t\t\t\taccumulator = isPromiseLike(reduced) ? await reduced : reduced;\n\t\t\t\tyield accumulator;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\tunion: (source) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst seenValues = /* @__PURE__ */ new Set();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (!seenValues.has(resolvedValue)) {\n\t\t\t\t\tseenValues.add(resolvedValue);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) if (!seenValues.has(value)) {\n\t\t\t\tseenValues.add(value);\n\t\t\t\tyield value;\n\t\t\t}\n\t\t\tif (isAsyncIterable(source)) {\n\t\t\t\tfor await (const value of source) if (!seenValues.has(value)) {\n\t\t\t\t\tseenValues.add(value);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t} else for (const value of source) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (!seenValues.has(resolvedValue)) {\n\t\t\t\t\tseenValues.add(resolvedValue);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t})),\n\t\tunionBy: (source, selector) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst seenKeys = /* @__PURE__ */ new Set();\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tindex = 0;\n\t\t\tif (isAsyncIterable(source)) for await (const value of source) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for (const value of source) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!seenKeys.has(key)) {\n\t\t\t\t\tseenKeys.add(key);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\tintersect: (source) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst rightValues = await collectValuesFromSource(source);\n\t\t\tconst yieldedValues = /* @__PURE__ */ new Set();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (rightValues.has(resolvedValue) && !yieldedValues.has(resolvedValue)) {\n\t\t\t\t\tyieldedValues.add(resolvedValue);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) if (rightValues.has(value) && !yieldedValues.has(value)) {\n\t\t\t\tyieldedValues.add(value);\n\t\t\t\tyield value;\n\t\t\t}\n\t\t})),\n\t\tintersectBy: (source, selector) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst rightKeys = await collectKeysFromSource(source, selector);\n\t\t\tconst yieldedKeys = /* @__PURE__ */ new Set();\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (rightKeys.has(key) && !yieldedKeys.has(key)) {\n\t\t\t\t\tyieldedKeys.add(key);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (rightKeys.has(key) && !yieldedKeys.has(key)) {\n\t\t\t\t\tyieldedKeys.add(key);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\texcept: (source) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst excludedValues = await collectValuesFromSource(source);\n\t\t\tconst yieldedValues = /* @__PURE__ */ new Set();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (!excludedValues.has(resolvedValue) && !yieldedValues.has(resolvedValue)) {\n\t\t\t\t\tyieldedValues.add(resolvedValue);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) if (!excludedValues.has(value) && !yieldedValues.has(value)) {\n\t\t\t\tyieldedValues.add(value);\n\t\t\t\tyield value;\n\t\t\t}\n\t\t})),\n\t\texceptBy: (source, selector) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst excludedKeys = await collectKeysFromSource(source, selector);\n\t\t\tconst yieldedKeys = /* @__PURE__ */ new Set();\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!excludedKeys.has(key) && !yieldedKeys.has(key)) {\n\t\t\t\t\tyieldedKeys.add(key);\n\t\t\t\t\tyield resolvedValue;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tif (!excludedKeys.has(key) && !yieldedKeys.has(key)) {\n\t\t\t\t\tyieldedKeys.add(key);\n\t\t\t\t\tyield value;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t})),\n\t\tchunkBySize: (size) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst normalizedSize = normalizeRequiredCount(size, \"Chunk size\");\n\t\t\tlet chunk = [];\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tchunk.push(isPromiseLike(value) ? await value : value);\n\t\t\t\tif (chunk.length >= normalizedSize) {\n\t\t\t\t\tyield chunk;\n\t\t\t\t\tchunk = [];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tchunk.push(value);\n\t\t\t\tif (chunk.length >= normalizedSize) {\n\t\t\t\t\tyield chunk;\n\t\t\t\t\tchunk = [];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (chunk.length > 0) yield chunk;\n\t\t})),\n\t\twindowed: (size) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst normalizedSize = normalizeRequiredCount(size, \"Window size\");\n\t\t\tconst buffer = new Array(normalizedSize);\n\t\t\tlet count = 0;\n\t\t\tlet nextIndex = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tbuffer[nextIndex] = isPromiseLike(value) ? await value : value;\n\t\t\t\tnextIndex = (nextIndex + 1) % normalizedSize;\n\t\t\t\tcount = Math.min(count + 1, normalizedSize);\n\t\t\t\tif (count < normalizedSize) continue;\n\t\t\t\tconst window = new Array(normalizedSize);\n\t\t\t\tfor (let index = 0; index < normalizedSize; index++) window[index] = buffer[(nextIndex + index) % normalizedSize];\n\t\t\t\tyield window;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tbuffer[nextIndex] = value;\n\t\t\t\tnextIndex = (nextIndex + 1) % normalizedSize;\n\t\t\t\tcount = Math.min(count + 1, normalizedSize);\n\t\t\t\tif (count < normalizedSize) continue;\n\t\t\t\tconst window = new Array(normalizedSize);\n\t\t\t\tfor (let index = 0; index < normalizedSize; index++) window[index] = buffer[(nextIndex + index) % normalizedSize];\n\t\t\t\tyield window;\n\t\t\t}\n\t\t})),\n\t\tflat,\n\t\treverse: () => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst values = await materializeValues(iteratorFactories);\n\t\t\tvalues.reverse();\n\t\t\tfor (const value of values) yield value;\n\t\t})),\n\t\ttoReversed: () => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst values = await materializeValues(iteratorFactories);\n\t\t\tfor (const value of [...values].reverse()) yield value;\n\t\t})),\n\t\tsort: (compareFn) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst values = await materializeValues(iteratorFactories);\n\t\t\tcompareFn === void 0 ? values.sort() : values.sort(compareFn);\n\t\t\tfor (const value of values) yield value;\n\t\t})),\n\t\ttoSorted: (compareFn) => createAsyncOperator(() => createAsyncIterable(async function* () {\n\t\t\tconst sortedValues = [...await materializeValues(iteratorFactories)];\n\t\t\tcompareFn === void 0 ? sortedValues.sort() : sortedValues.sort(compareFn);\n\t\t\tfor (const value of sortedValues) yield value;\n\t\t})),\n\t\tforEach: async (action) => {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = action(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tif (isPromiseLike(result)) await result;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = action(value, index);\n\t\t\t\tif (isPromiseLike(result)) await result;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t},\n\t\treduce,\n\t\treduceRight,\n\t\tsome: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = predicate(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return true;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return true;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\tevery: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = predicate(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tif (!(isPromiseLike(result) ? await result : result)) return false;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (!(isPromiseLike(result) ? await result : result)) return false;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t\tfind: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst result = predicate(resolvedValue, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return resolvedValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t},\n\t\tfindIndex: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = predicate(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) return index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn -1;\n\t\t},\n\t\tat: async (index) => {\n\t\t\tconst normalizedIndex = toIntegerOrInfinity(index);\n\t\t\tif (normalizedIndex >= 0) {\n\t\t\t\tif (normalizedIndex === Infinity) return;\n\t\t\t\tlet currentIndex = 0;\n\t\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\t\tif (currentIndex === normalizedIndex) return resolvedValue;\n\t\t\t\t\tcurrentIndex++;\n\t\t\t\t}\n\t\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\t\tif (currentIndex === normalizedIndex) return value;\n\t\t\t\t\tcurrentIndex++;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (normalizedIndex === -Infinity) return;\n\t\t\tconst lookback = Math.abs(normalizedIndex);\n\t\t\tconst buffer = new Array(lookback);\n\t\t\tlet count = 0;\n\t\t\tlet nextIndex = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tbuffer[nextIndex] = isPromiseLike(value) ? await value : value;\n\t\t\t\tnextIndex = (nextIndex + 1) % lookback;\n\t\t\t\tcount = Math.min(count + 1, lookback);\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tbuffer[nextIndex] = value;\n\t\t\t\tnextIndex = (nextIndex + 1) % lookback;\n\t\t\t\tcount = Math.min(count + 1, lookback);\n\t\t\t}\n\t\t\treturn count === lookback ? buffer[nextIndex] : void 0;\n\t\t},\n\t\tincludes: async (searchElement, fromIndex) => {\n\t\t\tconst normalizedFromIndex = toIntegerOrInfinity(fromIndex !== null && fromIndex !== void 0 ? fromIndex : 0);\n\t\t\tif (normalizedFromIndex < 0) return (await materializeValues(iteratorFactories)).includes(searchElement, normalizedFromIndex);\n\t\t\tif (normalizedFromIndex === Infinity) return false;\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (index >= normalizedFromIndex && sameValueZero(resolvedValue, searchElement)) return true;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tif (index >= normalizedFromIndex && sameValueZero(value, searchElement)) return true;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\tindexOf: async (searchElement, fromIndex) => {\n\t\t\tconst normalizedFromIndex = toIntegerOrInfinity(fromIndex !== null && fromIndex !== void 0 ? fromIndex : 0);\n\t\t\tif (normalizedFromIndex < 0) return (await materializeValues(iteratorFactories)).indexOf(searchElement, normalizedFromIndex);\n\t\t\tif (normalizedFromIndex === Infinity) return -1;\n\t\t\tlet index = 0;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (index >= normalizedFromIndex && resolvedValue === searchElement) return index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tif (index >= normalizedFromIndex && value === searchElement) return index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn -1;\n\t\t},\n\t\tlastIndexOf: async (searchElement, fromIndex) => {\n\t\t\tconst values = await materializeValues(iteratorFactories);\n\t\t\treturn fromIndex === void 0 ? values.lastIndexOf(searchElement) : values.lastIndexOf(searchElement, fromIndex);\n\t\t},\n\t\tfindLast: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tlet foundValue;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst result = predicate(resolvedValue, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) foundValue = resolvedValue;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) foundValue = value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn foundValue;\n\t\t},\n\t\tfindLastIndex: async (predicate) => {\n\t\t\tlet index = 0;\n\t\t\tlet foundIndex = -1;\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst result = predicate(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) foundIndex = index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst result = predicate(value, index);\n\t\t\t\tif (isPromiseLike(result) ? await result : result) foundIndex = index;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn foundIndex;\n\t\t},\n\t\tmin: async () => findExtremeBy(iteratorFactories, identity, \"min\"),\n\t\tminBy: async (selector) => findExtremeBy(iteratorFactories, selector, \"min\"),\n\t\tmax: async () => findExtremeBy(iteratorFactories, (value) => value, \"max\"),\n\t\tmaxBy: async (selector) => findExtremeBy(iteratorFactories, selector, \"max\"),\n\t\tgroupBy: async (selector) => {\n\t\t\tlet index = 0;\n\t\t\tconst groupedValues = /* @__PURE__ */ new Map();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tconst selectedKey = selector(resolvedValue, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tconst existingGroup = groupedValues.get(key);\n\t\t\t\tif (existingGroup) existingGroup.push(resolvedValue);\n\t\t\t\telse groupedValues.set(key, [resolvedValue]);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tconst existingGroup = groupedValues.get(key);\n\t\t\t\tif (existingGroup) existingGroup.push(value);\n\t\t\t\telse groupedValues.set(key, [value]);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn groupedValues;\n\t\t},\n\t\tcountBy: async (selector) => {\n\t\t\tlet index = 0;\n\t\t\tconst counts = /* @__PURE__ */ new Map();\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tvar _counts$get;\n\t\t\t\tconst selectedKey = selector(isPromiseLike(value) ? await value : value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tcounts.set(key, ((_counts$get = counts.get(key)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tvar _counts$get2;\n\t\t\t\tconst selectedKey = selector(value, index);\n\t\t\t\tconst key = isPromiseLike(selectedKey) ? await selectedKey : selectedKey;\n\t\t\t\tcounts.set(key, ((_counts$get2 = counts.get(key)) !== null && _counts$get2 !== void 0 ? _counts$get2 : 0) + 1);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\treturn counts;\n\t\t},\n\t\tjoin: async (separator) => {\n\t\t\tconst normalizedSeparator = separator !== null && separator !== void 0 ? separator : \",\";\n\t\t\tlet isFirst = true;\n\t\t\tlet result = \"\";\n\t\t\tif (syncFactory !== void 0) for (const value of syncFactory()) {\n\t\t\t\tconst resolvedValue = isPromiseLike(value) ? await value : value;\n\t\t\t\tif (!isFirst) result += normalizedSeparator;\n\t\t\t\tresult += resolvedValue == null ? \"\" : String(resolvedValue);\n\t\t\t\tisFirst = false;\n\t\t\t}\n\t\t\telse for await (const value of iterableFactory()) {\n\t\t\t\tif (!isFirst) result += normalizedSeparator;\n\t\t\t\tresult += value == null ? \"\" : String(value);\n\t\t\t\tisFirst = false;\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\ttoArray: async () => materializeValues(iteratorFactories)\n\t};\n};\n/**\n* Creates a chainable async operator pipeline from an iterable of values or promise-like values\n* @param source - Source iterable to resolve\n* @returns A lazy async operator pipeline\n*/\nvar from = (source) => createAsyncOperator(createIteratorFactories(source));\n//#endregion\nexport { createAsyncLocal, createMutex as createAsyncLock, createMutex, createConditional, createConditional as createSignal, createDeferred, createDeferredGenerator, createManuallyConditional, createManuallyConditional as createManuallySignal, createReaderWriterLock, createSemaphore, defer, delay, from, getCurrentLogicalContextId, getLogicalContextValue, onAbort, runOnNewLogicalContext, setLogicalContextValue };\n\n//# sourceMappingURL=index.mjs.map","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { spawn } from 'child_process';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst createAbortError = () => {\n const error = new Error('The operation was aborted.');\n error.name = 'AbortError';\n return error;\n};\n\nexport const runCommand = async (\n command: string,\n args: readonly string[],\n cwd: string,\n signal: AbortSignal | undefined\n) => {\n signal?.throwIfAborted();\n return new Promise<void>((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n cwd,\n stdio: 'inherit',\n });\n let settled = false;\n const onAbort = () => {\n if (settled) {\n return;\n }\n settled = true;\n child.kill();\n rejectPromise(createAbortError());\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n const cleanup = () => {\n signal?.removeEventListener('abort', onAbort);\n };\n child.once('error', (error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n rejectPromise(error);\n });\n child.once('close', (code) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n if (code === 0) {\n resolvePromise();\n return;\n }\n rejectPromise(\n new Error(\n `Command failed: ${command} ${args.join(' ')} (exit code ${code})`\n )\n );\n });\n });\n};\n\nexport const runCommandWithEnv = async (\n command: string,\n args: readonly string[],\n cwd: string,\n env: NodeJS.ProcessEnv,\n signal: AbortSignal | undefined\n) => {\n signal?.throwIfAborted();\n return new Promise<void>((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n cwd,\n env,\n stdio: 'inherit',\n });\n let settled = false;\n const onAbort = () => {\n if (settled) {\n return;\n }\n settled = true;\n child.kill();\n rejectPromise(createAbortError());\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n const cleanup = () => {\n signal?.removeEventListener('abort', onAbort);\n };\n child.once('error', (error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n rejectPromise(error);\n });\n child.once('close', (code) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n if (code === 0) {\n resolvePromise();\n return;\n }\n rejectPromise(\n new Error(\n `Command failed: ${command} ${args.join(' ')} (exit code ${code})`\n )\n );\n });\n });\n};\n\nexport const runCommandCapture = async (\n command: string,\n args: readonly string[],\n cwd: string,\n signal: AbortSignal | undefined\n) => {\n signal?.throwIfAborted();\n return new Promise<Buffer>((resolvePromise, rejectPromise) => {\n const stdoutChunks: Buffer[] = [];\n const stderrChunks: Buffer[] = [];\n const child = spawn(command, args, {\n cwd,\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let settled = false;\n const onAbort = () => {\n if (settled) {\n return;\n }\n settled = true;\n child.kill();\n rejectPromise(createAbortError());\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n const cleanup = () => {\n signal?.removeEventListener('abort', onAbort);\n };\n child.stdout.on('data', (chunk: Buffer) => {\n stdoutChunks.push(chunk);\n });\n child.stderr.on('data', (chunk: Buffer) => {\n stderrChunks.push(chunk);\n });\n child.once('error', (error) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n rejectPromise(error);\n });\n child.once('close', (code) => {\n if (settled) {\n return;\n }\n settled = true;\n cleanup();\n if (code === 0) {\n resolvePromise(Buffer.concat(stdoutChunks));\n return;\n }\n const stderrText = Buffer.concat(stderrChunks).toString('utf8');\n rejectPromise(\n new Error(\n `Command failed: ${command} ${args.join(' ')} (exit code ${code})${\n stderrText ? `\\n${stderrText}` : ''\n }`\n )\n );\n });\n });\n};\n","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { constants, access, mkdir } from 'fs/promises';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nexport const pathExists = async (targetPath: string) => {\n try {\n await access(targetPath, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nexport const ensureDirectory = async (targetPath: string) => {\n await mkdir(targetPath, { recursive: true });\n};\n","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { mkdtemp, rename, rm } from 'fs/promises';\nimport { homedir } from 'os';\nimport { join, resolve } from 'path';\nimport { createMutex } from 'async-primitives';\n\nimport { runCommand } from './commands';\nimport { ensureDirectory, pathExists } from './fs-utils';\nimport type { PrepareEmsdkOptions } from './types';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst DEFAULT_REPO_URL = 'https://github.com/emscripten-core/emsdk.git';\nconst DEFAULT_GIT_REF = 'main';\nconst DEFAULT_CACHE_DIR = join(homedir(), '.cache', 'emsdk-env');\nconst DEFAULT_TARGET_VERSION = 'latest';\n\nconst versionMutexes = new Map<string, ReturnType<typeof createMutex>>();\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst getVersionMutex = (key: string) => {\n let mutex = versionMutexes.get(key);\n if (!mutex) {\n mutex = createMutex();\n versionMutexes.set(key, mutex);\n }\n return mutex;\n};\n\nconst ensureNonEmpty = (value: string, label: string) => {\n if (value.trim().length === 0) {\n throw new TypeError(`${label} must be a non-empty string.`);\n }\n};\n\nconst sanitizeSegment = (value: string) => {\n const trimmed = value.trim();\n ensureNonEmpty(trimmed, 'targetVersion');\n const sanitized = trimmed.replace(/[^A-Za-z0-9._-]/g, '_');\n if (sanitized === '.' || sanitized === '..' || sanitized.length === 0) {\n throw new TypeError('targetVersion results in an unsafe path segment.');\n }\n return sanitized;\n};\n\nconst resolveEmsdkCommand = () =>\n process.platform === 'win32' ? 'emsdk.bat' : './emsdk';\n\nconst runEmsdk = async (\n repoDir: string,\n args: string[],\n signal: AbortSignal | undefined\n) => {\n if (process.platform === 'win32') {\n await runCommand('cmd', ['/c', 'emsdk.bat', ...args], repoDir, signal);\n return;\n }\n await runCommand(resolveEmsdkCommand(), args, repoDir, signal);\n};\n\nconst runGitClone = async (\n gitPath: string,\n repoUrl: string,\n targetDir: string,\n cwd: string,\n signal: AbortSignal | undefined\n) => {\n await runCommand(\n gitPath,\n ['clone', repoUrl, targetDir, '--depth', '1', '--branch', DEFAULT_GIT_REF],\n cwd,\n signal\n );\n};\n\nconst isAlreadyExistsError = (error: unknown) =>\n error instanceof Error &&\n 'code' in error &&\n (error as NodeJS.ErrnoException).code !== undefined &&\n ['EEXIST', 'ENOTEMPTY', 'EISDIR'].includes(\n String((error as NodeJS.ErrnoException).code)\n );\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Prepare the Emscripten SDK in the local cache and return the SDK root path.\n *\n * Clones the emsdk repository if needed, installs the requested version,\n * and activates it in the cache directory.\n *\n * @param options - SDK preparation options.\n * @returns Absolute path to the prepared SDK root.\n */\nexport const prepareEmsdk = async (\n options: PrepareEmsdkOptions\n): Promise<string> => {\n if (!options) {\n throw new TypeError('options must be provided.');\n }\n if (\n options.targetVersion !== undefined &&\n typeof options.targetVersion !== 'string'\n ) {\n throw new TypeError('targetVersion must be a string.');\n }\n const targetVersion = options.targetVersion ?? DEFAULT_TARGET_VERSION;\n ensureNonEmpty(targetVersion, 'targetVersion');\n options.signal?.throwIfAborted();\n\n const cacheDir = resolve(options.cacheDir ?? DEFAULT_CACHE_DIR);\n const repoUrl = options.repoUrl ?? DEFAULT_REPO_URL;\n const gitPath = options.gitPath ?? 'git';\n\n const versionDir = sanitizeSegment(targetVersion);\n const finalDir = resolve(cacheDir, versionDir);\n\n const mutex = getVersionMutex(finalDir);\n const lock = await mutex.lock(options.signal);\n try {\n options.signal?.throwIfAborted();\n if (await pathExists(finalDir)) {\n return finalDir;\n }\n\n await ensureDirectory(cacheDir);\n\n const tempRoot = await mkdtemp(join(cacheDir, '.tmp-'));\n const tempRepoDir = join(tempRoot, 'emsdk');\n\n try {\n await runGitClone(\n gitPath,\n repoUrl,\n tempRepoDir,\n cacheDir,\n options.signal\n );\n options.signal?.throwIfAborted();\n await runEmsdk(tempRepoDir, ['install', targetVersion], options.signal);\n\n try {\n await rename(tempRepoDir, finalDir);\n } catch (error) {\n if (isAlreadyExistsError(error)) {\n return finalDir;\n }\n throw error;\n }\n } finally {\n await rm(tempRoot, { recursive: true, force: true });\n }\n\n options.signal?.throwIfAborted();\n await runEmsdk(finalDir, ['activate', targetVersion], options.signal);\n return finalDir;\n } finally {\n lock.release();\n }\n};\n","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { join, resolve } from 'path';\n\nimport { runCommandCapture } from './commands';\nimport { pathExists } from './fs-utils';\nimport type { Logger } from './types';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst shellQuote = (value: string) =>\n `'${String(value).replace(/'/g, `'\\\"'\\\"'`)}'`;\n\nconst parseEnvBuffer = (buffer: Buffer) => {\n const entries = buffer.toString('utf8').split('\\u0000');\n const env: Record<string, string> = {};\n for (const entry of entries) {\n if (!entry) {\n continue;\n }\n const delimiterIndex = entry.indexOf('=');\n if (delimiterIndex <= 0) {\n continue;\n }\n const key = entry.slice(0, delimiterIndex);\n const value = entry.slice(delimiterIndex + 1);\n env[key] = value;\n }\n return env;\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nexport const loadEmsdkEnv = async (\n emsdkRoot: string,\n logger: Logger,\n signal: AbortSignal | undefined\n) => {\n if (process.platform === 'win32') {\n throw new Error(\n 'Emscripten environment extraction on Windows is not implemented yet.'\n );\n }\n const envScript = resolve(emsdkRoot, 'emsdk_env.sh');\n if (!(await pathExists(envScript))) {\n throw new Error(`emsdk_env.sh not found: ${envScript}`);\n }\n const command = `. ${shellQuote(envScript)} >/dev/null 2>&1; env -0`;\n logger.debug(`Loading emsdk environment: ${envScript}`);\n const output = await runCommandCapture(\n 'bash',\n ['-lc', command],\n emsdkRoot,\n signal\n );\n return parseEnvBuffer(output);\n};\n\nexport const resolveEmccCommand = async (\n env: Record<string, string>,\n emsdkRoot: string\n) => {\n if (env.EMCC) {\n return env.EMCC;\n }\n if (env.EMSCRIPTEN) {\n const candidate = join(env.EMSCRIPTEN, 'emcc');\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n const fallback = join(emsdkRoot, 'upstream', 'emscripten', 'emcc');\n if (await pathExists(fallback)) {\n return fallback;\n }\n return 'emcc';\n};\n\nexport const resolveEmarCommand = async (\n env: Record<string, string>,\n emsdkRoot: string\n) => {\n if (env.EMAR) {\n return env.EMAR;\n }\n if (env.EMSCRIPTEN) {\n const candidate = join(env.EMSCRIPTEN, 'emar');\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n const fallback = join(emsdkRoot, 'upstream', 'emscripten', 'emar');\n if (await pathExists(fallback)) {\n return fallback;\n }\n return 'emar';\n};\n\nexport const resolveWasmOptCommand = async (\n env: Record<string, string>,\n emsdkRoot: string\n) => {\n if (env.WASM_OPT) {\n return env.WASM_OPT;\n }\n const binaryenRoot = env.BINARYEN_ROOT ?? env.BINARYEN;\n if (binaryenRoot) {\n const candidate = join(binaryenRoot, 'bin', 'wasm-opt');\n if (await pathExists(candidate)) {\n return candidate;\n }\n }\n const fallback = join(emsdkRoot, 'upstream', 'bin', 'wasm-opt');\n if (await pathExists(fallback)) {\n return fallback;\n }\n return 'wasm-opt';\n};\n","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { Logger } from './types';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\n// Simple logger implementation with prefix\nexport const createConsoleLogger = (prefix: string): Logger => {\n return {\n debug: (msg: string) => console.debug(`[${prefix}]: ${msg}`),\n info: (msg: string) => console.info(`[${prefix}]: ${msg}`),\n warn: (msg: string) => console.warn(`[${prefix}]: ${msg}`),\n error: (msg: string) => console.error(`[${prefix}]: ${msg}`),\n };\n};\n","// emsdk-env - Emscripten environment builder\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/emsdk-env\n\nimport { readFile, rename, rm, writeFile } from 'fs/promises';\nimport { tmpdir } from 'os';\nimport { glob } from 'glob';\nimport { dirname, isAbsolute, join, parse, relative, resolve } from 'path';\n\nimport { runCommandWithEnv } from './commands';\nimport {\n loadEmsdkEnv,\n resolveEmarCommand,\n resolveEmccCommand,\n resolveWasmOptCommand,\n} from './env';\nimport { prepareEmsdk } from './emsdk';\nimport { ensureDirectory, pathExists } from './fs-utils';\nimport { createConsoleLogger } from './logger';\nimport type {\n BuildWasmOptions,\n BuildWasmResult,\n DefineInput,\n DefineValue,\n LinkDirectiveInput,\n LinkDirectiveValue,\n PrepareEmsdkOptions,\n WasmOptOptions,\n WasmBuildTargetType,\n} from './types';\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst DEFAULT_WASM_SRC_DIR = 'wasm';\nconst DEFAULT_WASM_INCLUDE_DIR = 'include';\nconst DEFAULT_WASM_OUT_DIR = join('src', 'wasm');\nconst DEFAULT_WASM_LIB_DIR = 'lib';\nconst DEFAULT_IMPORT_INCLUDE_DIR = 'include';\nconst DEFAULT_IMPORT_LIB_DIR = 'lib';\nconst DEFAULT_WASM_BUILD_DIR = join(tmpdir(), 'emsdk-env');\nconst DEFAULT_EMSDK_TARGET_VERSION = 'latest';\nconst DEFAULT_WASM_OPT_ARGS = ['-Oz'];\nconst DEFAULT_GENERATED_LOADER_OUT_FILE = join(\n 'src',\n 'generated',\n 'wasm-loader.ts'\n);\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nlet buildSequence = 0;\n\nconst padNumber = (value: number, length = 2) =>\n String(value).padStart(length, '0');\n\nconst formatTimestamp = (date: Date) => {\n const year = date.getFullYear();\n const month = padNumber(date.getMonth() + 1);\n const day = padNumber(date.getDate());\n const hour = padNumber(date.getHours());\n const minute = padNumber(date.getMinutes());\n const second = padNumber(date.getSeconds());\n return `${year}${month}${day}_${hour}${minute}${second}`;\n};\n\nconst createBuildId = () => {\n buildSequence += 1;\n const timestamp = formatTimestamp(new Date());\n const seq = String(buildSequence).padStart(4, '0');\n return `${timestamp}_${seq}_${process.pid}`;\n};\n\nconst ensureArray = (value?: readonly string[]) => value ?? [];\n\nconst resolveTargetType = (value: WasmBuildTargetType | undefined) =>\n value ?? 'wasm';\n\nconst normalizePrepareOptions = (\n options: PrepareEmsdkOptions | undefined\n): PrepareEmsdkOptions => {\n const { targetVersion, ...rest } = options ?? {};\n return {\n targetVersion: targetVersion ?? DEFAULT_EMSDK_TARGET_VERSION,\n ...rest,\n };\n};\n\nconst parseStringKeyValueInput = (values: readonly string[]) => {\n const parsed: Record<string, string | undefined> = {};\n for (const entry of values) {\n const index = entry.indexOf('=');\n if (index === -1) {\n parsed[entry] = undefined;\n continue;\n }\n const key = entry.slice(0, index);\n const value = entry.slice(index + 1);\n parsed[key] = value;\n }\n return parsed;\n};\n\nconst isDefineMap = (\n input: DefineInput\n): input is Readonly<Map<string, DefineValue>> => input instanceof Map;\n\nconst normalizeDefineInput = (\n input: DefineInput | undefined\n): Record<string, DefineValue> => {\n if (!input) {\n return {};\n }\n if (Array.isArray(input)) {\n return parseStringKeyValueInput(input);\n }\n if (isDefineMap(input)) {\n return Object.fromEntries(input);\n }\n return { ...(input as Record<string, DefineValue>) };\n};\n\nconst isLinkDirectiveMap = (\n input: LinkDirectiveInput\n): input is Readonly<Map<string, LinkDirectiveValue>> => input instanceof Map;\n\nconst normalizeLinkDirectiveInput = (\n input: LinkDirectiveInput | undefined\n): Record<string, LinkDirectiveValue> => {\n if (!input) {\n return {};\n }\n if (Array.isArray(input)) {\n return parseStringKeyValueInput(input);\n }\n if (isLinkDirectiveMap(input)) {\n return Object.fromEntries(input);\n }\n return { ...(input as Record<string, LinkDirectiveValue>) };\n};\n\nconst mergeDefines = (\n common?: DefineInput,\n target?: DefineInput\n): Record<string, DefineValue> => ({\n ...normalizeDefineInput(common),\n ...normalizeDefineInput(target),\n});\n\nconst mergeLinkDirectives = (\n common?: LinkDirectiveInput,\n target?: LinkDirectiveInput\n): Record<string, LinkDirectiveValue> => ({\n ...normalizeLinkDirectiveInput(common),\n ...normalizeLinkDirectiveInput(target),\n});\n\nconst resolveWasmOptEnabled = (\n common: WasmOptOptions | undefined,\n target: WasmOptOptions | undefined\n) => target?.enable ?? common?.enable ?? false;\n\nconst resolveWasmOptArgs = (\n common: WasmOptOptions | undefined,\n target: WasmOptOptions | undefined,\n env: Record<string, string>\n) => {\n const commonArgs = common?.options ?? DEFAULT_WASM_OPT_ARGS;\n const targetArgs = target?.options ?? [];\n const mergedArgs = [...commonArgs, ...targetArgs];\n return expandArray(mergedArgs, env, 'wasmOpt.options');\n};\n\nconst stripOuterQuotes = (value: string) => {\n const trimmed = value.trim();\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n return trimmed;\n};\n\nconst extractWasmBinaryFile = (value: string) => {\n if (value.startsWith('WASM_BINARY_FILE=')) {\n return value.slice('WASM_BINARY_FILE='.length);\n }\n const match = value.match(/^(?:-s|--settings)(?:=)?WASM_BINARY_FILE=(.+)$/);\n if (match) {\n return match[1];\n }\n return undefined;\n};\n\nconst resolveWasmBinaryFileFromLinkOptions = (\n linkOptions: readonly string[]\n) => {\n for (let index = 0; index < linkOptions.length; index += 1) {\n const option = linkOptions[index];\n if (!option) {\n continue;\n }\n if (option === '-s' || option === '--settings') {\n const next = linkOptions[index + 1];\n if (!next) {\n continue;\n }\n const extracted = extractWasmBinaryFile(next);\n if (extracted) {\n return stripOuterQuotes(extracted);\n }\n }\n const extracted = extractWasmBinaryFile(option);\n if (extracted) {\n return stripOuterQuotes(extracted);\n }\n }\n return undefined;\n};\n\nconst resolveWasmOptInputFile = (\n resolvedOutFile: string,\n resolvedLinkOptions: readonly string[]\n) => {\n const wasmBinaryFile =\n resolveWasmBinaryFileFromLinkOptions(resolvedLinkOptions);\n if (wasmBinaryFile) {\n return isAbsolute(wasmBinaryFile)\n ? wasmBinaryFile\n : resolve(dirname(resolvedOutFile), wasmBinaryFile);\n }\n const parsed = parse(resolvedOutFile);\n if (parsed.ext.toLowerCase() === '.wasm') {\n return resolvedOutFile;\n }\n const baseName = parsed.name.toLowerCase().endsWith('.wasm')\n ? parsed.name\n : `${parsed.name}.wasm`;\n return join(parsed.dir, baseName);\n};\n\nconst resolvePath = (rootDir: string, value: string) =>\n isAbsolute(value) ? value : resolve(rootDir, value);\n\nconst expandPlaceholders = (\n value: string,\n env: Record<string, string>,\n label: string\n) =>\n value.replace(/\\{([A-Z0-9_]+)\\}/g, (_match, key: string) => {\n const replacement = env[key];\n if (replacement === undefined) {\n throw new Error(`Unknown placeholder {${key}} in ${label}.`);\n }\n return replacement;\n });\n\nconst expandArray = (\n values: readonly string[],\n env: Record<string, string>,\n label: string\n) => values.map((value) => expandPlaceholders(value, env, label));\n\nconst resolveDefines = (\n defines: Record<string, DefineValue>,\n env: Record<string, string>\n) => {\n const resolved: Record<string, DefineValue> = {};\n for (const [key, value] of Object.entries(defines)) {\n if (typeof value === 'string') {\n resolved[key] = expandPlaceholders(value, env, `defines.${key}`);\n } else {\n resolved[key] = value;\n }\n }\n return resolved;\n};\n\nconst resolveLinkDirectiveValue = (\n value: LinkDirectiveValue,\n env: Record<string, string>,\n label: string\n): LinkDirectiveValue => {\n if (typeof value === 'string') {\n return expandPlaceholders(value, env, label);\n }\n if (Array.isArray(value)) {\n return value.map((entry, index) =>\n expandPlaceholders(entry, env, `${label}[${index}]`)\n );\n }\n return value;\n};\n\nconst resolveLinkDirectives = (\n directives: Record<string, LinkDirectiveValue>,\n env: Record<string, string>\n) => {\n const resolved: Record<string, LinkDirectiveValue> = {};\n for (const [key, value] of Object.entries(directives)) {\n resolved[key] = resolveLinkDirectiveValue(\n value,\n env,\n `linkDirectives.${key}`\n );\n }\n return resolved;\n};\n\nconst resolveIncludeDirs = (\n includeDirs: readonly string[],\n env: Record<string, string>,\n rootDir: string\n) => {\n const expanded = expandArray(includeDirs, env, 'includeDirs');\n return expanded.map((value) => resolvePath(rootDir, value));\n};\n\nconst resolveOutFile = (\n outFile: string,\n env: Record<string, string>,\n outDir: string\n) => {\n const expanded = expandPlaceholders(outFile, env, 'outFile');\n return resolvePath(outDir, expanded);\n};\n\nconst resolveSourcesFromPatterns = async (\n patterns: readonly string[],\n env: Record<string, string>,\n srcDir: string,\n label: string\n) => {\n const expanded = expandArray(patterns, env, label);\n const resolvedPatterns = expanded.map((value) => resolvePath(srcDir, value));\n const results = await Promise.all(\n resolvedPatterns.map((pattern) => glob(pattern, { nodir: true }))\n );\n const sources = results.flat();\n sources.sort();\n return sources;\n};\n\nconst buildDefineFlags = (defines: Record<string, DefineValue>) =>\n Object.entries(defines).flatMap(([key, value]) =>\n value === null || value === undefined\n ? [`-D${key}`]\n : [`-D${key}=${String(value)}`]\n );\n\nconst serializeLinkDirectiveValue = (\n value: Exclude<LinkDirectiveValue, null | undefined>\n) => (Array.isArray(value) ? JSON.stringify(value) : String(value));\n\nconst buildLinkDirectiveFlags = (\n directives: Record<string, LinkDirectiveValue>\n) => {\n if (Object.keys(directives).length === 0) {\n return [];\n }\n return Object.entries(directives).flatMap(([key, value]) =>\n value === null || value === undefined\n ? ['-s', key]\n : ['-s', `${key}=${serializeLinkDirectiveValue(value)}`]\n );\n};\n\nconst buildExportFlags = (exports: readonly string[]) => {\n if (exports.length === 0) {\n return [];\n }\n return ['-s', `EXPORTED_FUNCTIONS=${JSON.stringify(exports)}`];\n};\n\nconst createEnvForBuild = (\n baseEnv: Record<string, string>,\n overrides: Record<string, string>\n) => ({\n ...process.env,\n ...baseEnv,\n ...overrides,\n});\n\nconst resolveTargetOutFile = (\n targetName: string,\n targetOutFile: string | undefined,\n env: Record<string, string>,\n baseDir: string,\n extension: string\n) => {\n if (targetOutFile) {\n return resolveOutFile(targetOutFile, env, baseDir);\n }\n return resolve(baseDir, `${targetName}.${extension}`);\n};\n\nconst resolveTargetSources = async (\n targetSources: readonly string[] | undefined,\n env: Record<string, string>,\n srcDir: string\n) => {\n const patterns =\n targetSources && targetSources.length > 0\n ? targetSources\n : [join(srcDir, '**', '*.c'), join(srcDir, '**', '*.cpp')];\n return resolveSourcesFromPatterns(patterns, env, srcDir, 'sources');\n};\n\nconst toSafeObjectName = (\n rootDir: string,\n sourcePath: string,\n groupIndex?: number\n) => {\n const baseName = relative(rootDir, sourcePath)\n .replace(/[\\\\/]/g, '_')\n .replace(/[^A-Za-z0-9._-]/g, '_');\n if (groupIndex === undefined) {\n return baseName;\n }\n return `${baseName}__g${groupIndex}`;\n};\n\nconst dedupeSources = (sources: string[]) => {\n const seen = new Set<string>();\n const deduped: string[] = [];\n for (const source of sources) {\n if (seen.has(source)) {\n continue;\n }\n seen.add(source);\n deduped.push(source);\n }\n return deduped;\n};\n\nconst dedupeValues = (values: readonly string[]) => {\n const seen = new Set<string>();\n const deduped: string[] = [];\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n deduped.push(value);\n }\n return deduped;\n};\n\nconst isSubPath = (parentDir: string, targetPath: string) => {\n const rel = relative(parentDir, targetPath);\n if (rel === '') {\n return true;\n }\n return !rel.startsWith('..') && !isAbsolute(rel);\n};\n\nconst readTextIfExists = async (filePath: string) => {\n try {\n return await readFile(filePath, 'utf8');\n } catch (error) {\n const nodeError = error as NodeJS.ErrnoException;\n if (nodeError.code === 'ENOENT') {\n return undefined;\n }\n throw error;\n }\n};\n\nconst writeTextIfChanged = async (filePath: string, content: string) => {\n const existing = await readTextIfExists(filePath);\n if (existing === content) {\n return false;\n }\n await ensureDirectory(dirname(filePath));\n await writeFile(filePath, content, 'utf8');\n return true;\n};\n\nconst toPascalCaseIdentifier = (value: string) => {\n const tokens = value\n .split(/[^A-Za-z0-9]+/)\n .map((token) => token.trim())\n .filter((token) => token.length > 0);\n if (tokens.length === 0) {\n throw new Error(`Cannot derive loader function name from target: ${value}`);\n }\n const pascal = tokens\n .map((token) => token.charAt(0).toUpperCase() + token.slice(1))\n .join('');\n return /^[0-9]/.test(pascal) ? `Target${pascal}` : pascal;\n};\n\ntype GeneratedLoaderTarget = {\n targetName: string;\n functionName: string;\n outFile: string;\n};\n\nconst toRelativeImportSpecifier = (fromFile: string, toFile: string) => {\n const rel = relative(dirname(fromFile), toFile).replace(/\\\\/g, '/');\n return rel.startsWith('.') ? rel : `./${rel}`;\n};\n\nconst buildGeneratedLoaderContent = (\n generatedLoaderFile: string,\n targets: readonly GeneratedLoaderTarget[]\n) => {\n const targetBlocks = targets\n .map((target) => {\n const defaultSourceSpecifier = toRelativeImportSpecifier(\n generatedLoaderFile,\n target.outFile\n );\n const specifier = JSON.stringify(defaultSourceSpecifier);\n return `/**\n * Load and instantiate the generated \"${target.targetName}\" WASM target.\n *\n * @typeParam TExports Function exports exposed through the exports property.\n * @typeParam TAllExports Full WebAssembly export map exposed through the allExports property.\n * @param options Override the target source or WebAssembly imports.\n * @returns The instantiated WASM target and resolved runtime handles.\n * @remarks When options.source is omitted, the loader resolves \"${defaultSourceSpecifier}\" relative to this file.\n */\nexport const ${target.functionName} = async <\n TExports extends object = Record<string, (...args: unknown[]) => unknown>,\n TAllExports extends WebAssembly.Exports = WebAssembly.Exports>(\n options?: TargetWasmLoadOptions\n): Promise<WasmInstance<TExports, TAllExports>> => {\n const source = options?.source ?? new URL(${specifier}, import.meta.url);\n return await loadWasm<TExports, TAllExports>(source, createWasmLoadOptions(options?.imports));\n};`;\n })\n .join('\\n\\n');\n\n return `// Generated by emsdk-env. DO NOT EDIT.\n\n/**\n * Supported input sources for loading a WASM binary.\n */\nexport type WasmSource =\n | string\n | URL\n | ArrayBuffer\n | ArrayBufferView\n | Response;\n\n/**\n * Options for instantiating a WASM module.\n */\nexport interface WasmLoadOptions {\n /**\n * Imports passed to WebAssembly.instantiate().\n */\n readonly imports?: WebAssembly.Imports;\n}\n\n/**\n * Options for loading a generated WASM target.\n */\nexport interface TargetWasmLoadOptions extends WasmLoadOptions {\n /**\n * Override the generated default source for the target.\n */\n readonly source?: WasmSource;\n}\n\nconst isResponse = (value: WasmSource): value is Response =>\n typeof Response !== 'undefined' && value instanceof Response;\n\nconst createWasmLoadOptions = (\n imports: WebAssembly.Imports | undefined\n): WasmLoadOptions | undefined => (imports ? { imports } : undefined);\n\n/**\n * Instantiated WASM module with typed export helpers.\n *\n * @typeParam TExports Function exports exposed through the exports property.\n * @typeParam TAllExports Full WebAssembly export map exposed through the allExports property.\n */\nexport interface WasmInstance<\n TExports extends object = Record<string, (...args: unknown[]) => unknown>,\n TAllExports extends WebAssembly.Exports = WebAssembly.Exports> {\n /**\n * Exported functions only.\n */\n readonly exports: TExports;\n /**\n * All exported values with caller-provided typing.\n */\n readonly allExports: TAllExports;\n /**\n * Resolved linear memory used by the module.\n */\n readonly memory: WebAssembly.Memory;\n /**\n * Resolved function table when the module uses one.\n */\n readonly table: WebAssembly.Table | undefined;\n /**\n * Raw exports object returned by WebAssembly.instantiate().\n */\n readonly rawExports: WebAssembly.Exports;\n /**\n * Compiled WebAssembly module.\n */\n readonly module: WebAssembly.Module;\n /**\n * Instantiated WebAssembly instance.\n */\n readonly instance: WebAssembly.Instance;\n /**\n * Optional Emscripten _initialize export.\n */\n readonly initialize: (() => unknown) | undefined;\n /**\n * Optional WASI _start export.\n */\n readonly start: (() => unknown) | undefined;\n}\n\nconst resolveWasmBytes = async (source: WasmSource): Promise<ArrayBuffer> => {\n if (isResponse(source)) {\n return await source.arrayBuffer();\n }\n if (source instanceof URL || typeof source === 'string') {\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(\\`Failed to fetch wasm: \\${response.url}\\`);\n }\n return await response.arrayBuffer();\n }\n if (source instanceof ArrayBuffer) {\n return source;\n }\n if (ArrayBuffer.isView(source)) {\n const view = new Uint8Array(\n source.buffer,\n source.byteOffset,\n source.byteLength\n );\n return view.slice().buffer;\n }\n throw new TypeError('Unsupported wasm source.');\n};\n\nconst getImportValue = (\n imports: WebAssembly.Imports | undefined,\n moduleName: string,\n name: string\n) => {\n const moduleImports = imports?.[moduleName];\n if (!moduleImports || typeof moduleImports !== 'object') {\n return undefined;\n }\n return (moduleImports as Record<string, unknown>)[name];\n};\n\nconst resolveMemory = (\n module: WebAssembly.Module,\n instance: WebAssembly.Instance,\n imports: WebAssembly.Imports | undefined\n) => {\n let memory: WebAssembly.Memory | undefined;\n for (const entry of WebAssembly.Module.exports(module)) {\n if (entry.kind !== 'memory') {\n continue;\n }\n if (memory) {\n throw new Error('Multiple wasm memories are not supported.');\n }\n const value = instance.exports[entry.name];\n if (!(value instanceof WebAssembly.Memory)) {\n throw new Error(\\`Export is not a WebAssembly.Memory: \\${entry.name}\\`);\n }\n memory = value;\n }\n if (memory) {\n return memory;\n }\n for (const entry of WebAssembly.Module.imports(module)) {\n if (entry.kind !== 'memory') {\n continue;\n }\n if (memory) {\n throw new Error('Multiple wasm memories are not supported.');\n }\n const value = getImportValue(imports, entry.module, entry.name);\n if (!(value instanceof WebAssembly.Memory)) {\n throw new Error(\n \\`Imported value is not a WebAssembly.Memory: \\${entry.module}.\\${entry.name}\\`\n );\n }\n memory = value;\n }\n if (!memory) {\n throw new Error('WASM memory export/import was not resolved.');\n }\n return memory;\n};\n\nconst resolveTable = (\n module: WebAssembly.Module,\n instance: WebAssembly.Instance,\n imports: WebAssembly.Imports | undefined\n) => {\n let table: WebAssembly.Table | undefined;\n for (const entry of WebAssembly.Module.exports(module)) {\n if (entry.kind !== 'table') {\n continue;\n }\n if (table) {\n throw new Error('Multiple wasm tables are not supported.');\n }\n const value = instance.exports[entry.name];\n if (!(value instanceof WebAssembly.Table)) {\n throw new Error(\\`Export is not a WebAssembly.Table: \\${entry.name}\\`);\n }\n table = value;\n }\n if (table) {\n return table;\n }\n for (const entry of WebAssembly.Module.imports(module)) {\n if (entry.kind !== 'table') {\n continue;\n }\n if (table) {\n throw new Error('Multiple wasm tables are not supported.');\n }\n const value = getImportValue(imports, entry.module, entry.name);\n if (!(value instanceof WebAssembly.Table)) {\n throw new Error(\n \\`Imported value is not a WebAssembly.Table: \\${entry.module}.\\${entry.name}\\`\n );\n }\n table = value;\n }\n return table;\n};\n\n/**\n * Load and instantiate a WASM module from the provided source.\n *\n * @typeParam TExports Function exports exposed through the exports property.\n * @typeParam TAllExports Full WebAssembly export map exposed through the allExports property.\n * @param source WASM source to load.\n * @param options WebAssembly instantiation options.\n * @returns The instantiated WASM module and resolved runtime handles.\n */\nexport const loadWasm = async <\n TExports extends object = Record<string, (...args: unknown[]) => unknown>,\n TAllExports extends WebAssembly.Exports = WebAssembly.Exports>(\n source: WasmSource,\n options?: WasmLoadOptions\n): Promise<WasmInstance<TExports, TAllExports>> => {\n const bytes = await resolveWasmBytes(source);\n const module = await WebAssembly.compile(bytes);\n const instance = await WebAssembly.instantiate(module, options?.imports ?? {});\n\n const functionExports: Record<string, (...args: unknown[]) => unknown> = {};\n for (const entry of WebAssembly.Module.exports(module)) {\n if (entry.kind !== 'function') {\n continue;\n }\n const value = instance.exports[entry.name];\n if (typeof value !== 'function') {\n throw new Error(\\`Export is not a function: \\${entry.name}\\`);\n }\n functionExports[entry.name] = value as (...args: unknown[]) => unknown;\n }\n\n const initialize =\n typeof instance.exports._initialize === 'function'\n ? (instance.exports._initialize as () => unknown)\n : undefined;\n const start =\n typeof instance.exports._start === 'function'\n ? (instance.exports._start as () => unknown)\n : undefined;\n\n return {\n exports: functionExports as TExports,\n allExports: instance.exports as TAllExports,\n memory: resolveMemory(module, instance, options?.imports),\n table: resolveTable(module, instance, options?.imports),\n rawExports: instance.exports,\n module,\n instance,\n initialize,\n start,\n };\n};\n\n${targetBlocks}\n`;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst resolvePackageJsonPath = async (\n startPath: string,\n packageName: string\n) => {\n let current = dirname(startPath);\n for (;;) {\n const candidate = join(current, 'package.json');\n if (await pathExists(candidate)) {\n return candidate;\n }\n const parent = dirname(current);\n if (parent === current) {\n throw new Error(`package.json not found for import: ${packageName}`);\n }\n current = parent;\n }\n};\n\nconst loadPackageJson = async (\n packageJsonPath: string,\n packageName: string\n) => {\n try {\n const raw = await readFile(packageJsonPath, 'utf8');\n const parsed = JSON.parse(raw);\n if (!isRecord(parsed)) {\n throw new Error('package.json must be an object.');\n }\n return parsed;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to read package.json for import ${packageName}: ${message}`\n );\n }\n};\n\nconst resolveImportPaths = async (\n resolver: NodeJS.Require,\n packageName: string\n) => {\n let resolvedEntry: string;\n try {\n resolvedEntry = resolver.resolve(packageName);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Failed to resolve import ${packageName}: ${message}`);\n }\n\n const packageJsonPath = await resolvePackageJsonPath(\n resolvedEntry,\n packageName\n );\n const packageRoot = dirname(packageJsonPath);\n const packageJson = await loadPackageJson(packageJsonPath, packageName);\n const emsdkConfigRaw = packageJson['emsdk-env'];\n if (emsdkConfigRaw !== undefined && !isRecord(emsdkConfigRaw)) {\n throw new Error(\n `Invalid emsdk-env config for import ${packageName}: expected an object.`\n );\n }\n\n const includeRaw = isRecord(emsdkConfigRaw)\n ? emsdkConfigRaw.include\n : undefined;\n if (includeRaw !== undefined && typeof includeRaw !== 'string') {\n throw new Error(\n `Invalid emsdk-env include for import ${packageName}: expected a string.`\n );\n }\n const libRaw = isRecord(emsdkConfigRaw) ? emsdkConfigRaw.lib : undefined;\n if (libRaw !== undefined && typeof libRaw !== 'string') {\n throw new Error(\n `Invalid emsdk-env lib for import ${packageName}: expected a string.`\n );\n }\n\n const includeRel = includeRaw ?? DEFAULT_IMPORT_INCLUDE_DIR;\n const libRel = libRaw ?? DEFAULT_IMPORT_LIB_DIR;\n const includeDir = resolve(packageRoot, includeRel);\n const libDir = resolve(packageRoot, libRel);\n const includeExists = await pathExists(includeDir);\n const libExists = await pathExists(libDir);\n if (!includeExists && !libExists) {\n throw new Error(\n `Import ${packageName} does not provide include or lib directories.`\n );\n }\n return {\n includeDir: includeExists ? includeDir : undefined,\n libDir: libExists ? libDir : undefined,\n };\n};\n\nconst resolveImportDirectories = async (\n rootDir: string,\n imports: readonly string[]\n) => {\n if (imports.length === 0) {\n return { includeDirs: [], libDirs: [] };\n }\n const moduleApi = await import('node:module');\n const resolver = moduleApi.createRequire(resolve(rootDir, 'package.json'));\n const includeDirs: string[] = [];\n const libDirs: string[] = [];\n for (const packageName of imports) {\n const resolved = await resolveImportPaths(resolver, packageName);\n if (resolved.includeDir) {\n includeDirs.push(resolved.includeDir);\n }\n if (resolved.libDir) {\n libDirs.push(resolved.libDir);\n }\n }\n return {\n includeDirs: dedupeValues(includeDirs),\n libDirs: dedupeValues(libDirs),\n };\n};\n\nconst resolveGeneratedLoaderOutFile = (\n rootDir: string,\n env: Record<string, string>,\n generatedLoader: BuildWasmOptions['generatedLoader']\n) => {\n if (!generatedLoader?.enable) {\n return undefined;\n }\n const rawOutFile = expandPlaceholders(\n generatedLoader.outFile ?? DEFAULT_GENERATED_LOADER_OUT_FILE,\n env,\n 'generatedLoader.outFile'\n );\n return resolvePath(rootDir, rawOutFile);\n};\n\nconst resolveGeneratedLoaderWatchDirs = (\n rootDir: string,\n srcDir: string,\n commonIncludeDirs: readonly string[],\n env: Record<string, string>,\n targetEntries: readonly [string, { includeDirs?: readonly string[] }][],\n importIncludeDirs: readonly string[]\n) => {\n const dirs = [srcDir, ...resolveIncludeDirs(commonIncludeDirs, env, rootDir)];\n for (const [targetName, target] of targetEntries) {\n if (!target.includeDirs || target.includeDirs.length === 0) {\n continue;\n }\n const targetEnv = {\n ...env,\n TARGET_NAME: targetName,\n };\n dirs.push(...resolveIncludeDirs(target.includeDirs, targetEnv, rootDir));\n }\n dirs.push(...importIncludeDirs);\n return dedupeValues(dirs);\n};\n\nconst validateGeneratedLoaderOutFile = (\n generatedLoaderFile: string,\n watchDirs: readonly string[]\n) => {\n for (const dir of watchDirs) {\n if (isSubPath(dir, generatedLoaderFile)) {\n throw new Error(\n `generatedLoader.outFile must not be placed under watched directory: ${generatedLoaderFile}`\n );\n }\n }\n};\n\ntype CompileArgs = {\n resolvedOptions: readonly string[];\n includeArgs: readonly string[];\n defineArgs: readonly string[];\n};\n\nconst buildCompileArgs = (\n options: readonly string[],\n includeDirs: readonly string[],\n defines: Record<string, DefineValue>,\n env: Record<string, string>,\n rootDir: string\n): CompileArgs => {\n const resolvedOptions = expandArray(options, env, 'options');\n const includeArgs = resolveIncludeDirs(includeDirs, env, rootDir).map(\n (dir) => `-I${dir}`\n );\n const defineArgs = buildDefineFlags(resolveDefines(defines, env));\n return { resolvedOptions, includeArgs, defineArgs };\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Build WASM binaries (and optional archives) from C/C++ sources using emsdk.\n *\n * Resolves the SDK via prepareEmsdk, expands build paths, compiles sources,\n * links targets, and returns output paths keyed by target name.\n *\n * @param options - Build options including rule definitions and shared settings.\n * @returns Build result with the resolved SDK root and output file paths.\n */\nexport const buildWasm = async (\n options: BuildWasmOptions\n): Promise<BuildWasmResult> => {\n if (!options) {\n throw new TypeError('options must be provided.');\n }\n if (!options.rule || !options.rule.targets) {\n throw new TypeError('rule targets must be provided.');\n }\n const targetEntries = Object.entries(options.rule.targets);\n if (targetEntries.length === 0) {\n throw new TypeError('rule targets must not be empty.');\n }\n\n const logger = options.logger ?? createConsoleLogger('emsdk-env');\n const rootDir = resolve(options.root ?? process.cwd());\n\n const emsdkOptions = normalizePrepareOptions(options.emsdk);\n const emsdkRoot = await prepareEmsdk(emsdkOptions);\n const emsdkEnv = await loadEmsdkEnv(emsdkRoot, logger, emsdkOptions.signal);\n\n const baseEnv = {\n ...emsdkEnv,\n ROOT: rootDir,\n };\n\n const rawSrcDir = expandPlaceholders(\n options.srcDir ?? DEFAULT_WASM_SRC_DIR,\n baseEnv,\n 'srcDir'\n );\n const rawIncludeDir = expandPlaceholders(\n options.includeDir ?? DEFAULT_WASM_INCLUDE_DIR,\n baseEnv,\n 'includeDir'\n );\n const rawOutDir = expandPlaceholders(\n options.outDir ?? DEFAULT_WASM_OUT_DIR,\n baseEnv,\n 'outDir'\n );\n const rawLibDir = expandPlaceholders(\n options.libDir ?? DEFAULT_WASM_LIB_DIR,\n baseEnv,\n 'libDir'\n );\n const rawBuildDir = expandPlaceholders(\n options.buildDir ?? DEFAULT_WASM_BUILD_DIR,\n baseEnv,\n 'buildDir'\n );\n\n const srcDir = resolvePath(rootDir, rawSrcDir);\n const includeDir = resolvePath(rootDir, rawIncludeDir);\n const outDir = resolvePath(rootDir, rawOutDir);\n const libDir = resolvePath(rootDir, rawLibDir);\n const buildDir = resolvePath(rootDir, rawBuildDir);\n const buildId = createBuildId();\n const buildRunDir = resolve(buildDir, buildId);\n const cleanupBuildDir = options.cleanupBuildDir ?? true;\n const parallel = options.parallel ?? true;\n\n const envWithDirs = {\n ...emsdkEnv,\n ROOT: rootDir,\n SRC_DIR: srcDir,\n INCLUDE_DIR: includeDir,\n OUT_DIR: outDir,\n LIB_DIR: libDir,\n BUILD_DIR: buildDir,\n };\n\n const emccCommand = await resolveEmccCommand(envWithDirs, emsdkRoot);\n const common = options.rule.common ?? {};\n const commonIncludeDirs =\n common.includeDirs === undefined ? [includeDir] : common.includeDirs;\n const importDirectories = await resolveImportDirectories(\n rootDir,\n ensureArray(options.imports)\n );\n const importIncludeDirs = importDirectories.includeDirs;\n const importLibDirs = importDirectories.libDirs;\n const linkLibDirs = dedupeValues([libDir, ...importLibDirs]);\n const generatedLoaderFile = resolveGeneratedLoaderOutFile(\n rootDir,\n envWithDirs,\n options.generatedLoader\n );\n if (generatedLoaderFile) {\n const watchDirs = resolveGeneratedLoaderWatchDirs(\n rootDir,\n srcDir,\n commonIncludeDirs,\n envWithDirs,\n targetEntries as [string, { includeDirs?: readonly string[] }][],\n importIncludeDirs\n );\n validateGeneratedLoaderOutFile(generatedLoaderFile, watchDirs);\n }\n\n // Outputs path variables in debug\n logger.debug(`Detected rootDir: '${rootDir}'`);\n logger.debug(`Detected srcDir: '${srcDir}'`);\n logger.debug(`Detected outDir: '${outDir}'`);\n logger.debug(`Detected libDir: '${libDir}'`);\n logger.debug(`Detected buildDir: '${buildDir}'`);\n logger.debug(`Detected buildId: '${buildId}'`);\n logger.debug(`Detected buildRunDir: '${buildRunDir}'`);\n logger.debug(`Detected cleanupBuildDir: ${cleanupBuildDir}`);\n logger.debug(`Detected parallel: ${parallel}`);\n logger.debug(`Detected emccCommand: '${emccCommand}'`);\n logger.debug(\n `Detected importIncludeDirs: [${importIncludeDirs.map((p) => `'${p}'`).join(',')}]`\n );\n logger.debug(\n `Detected importLibDirs: [${importLibDirs.map((p) => `'${p}'`).join(',')}]`\n );\n if (generatedLoaderFile) {\n logger.debug(`Detected generatedLoaderFile: '${generatedLoaderFile}'`);\n }\n\n await ensureDirectory(outDir);\n await ensureDirectory(libDir);\n await ensureDirectory(buildDir);\n await rm(buildRunDir, { recursive: true, force: true });\n await ensureDirectory(buildRunDir);\n\n const hasArchiveTargets = targetEntries.some(\n ([, target]) => resolveTargetType(target.type) === 'archive'\n );\n const emarCommand = hasArchiveTargets\n ? await resolveEmarCommand(envWithDirs, emsdkRoot)\n : undefined;\n if (emarCommand) {\n logger.debug(`Detected emarCommand: '${emarCommand}'`);\n }\n let wasmOptCommand: string | undefined;\n const getWasmOptCommand = async () => {\n if (wasmOptCommand) {\n return wasmOptCommand;\n }\n wasmOptCommand = await resolveWasmOptCommand(envWithDirs, emsdkRoot);\n logger.debug(`Detected wasmOptCommand: '${wasmOptCommand}'`);\n return wasmOptCommand;\n };\n\n const outFiles: Record<string, string> = {};\n let resultGeneratedLoaderFile: string | undefined;\n\n const buildTargets = async (expectedType: WasmBuildTargetType) => {\n for (const [targetName, target] of targetEntries) {\n const targetType = resolveTargetType(target.type);\n if (targetType !== expectedType) {\n continue;\n }\n if (targetType === 'archive') {\n if (target.linkOptions !== undefined) {\n throw new Error(\n `linkOptions is not supported for archive target: ${targetName}`\n );\n }\n if (target.linkDirectives !== undefined) {\n throw new Error(\n `linkDirectives is not supported for archive target: ${targetName}`\n );\n }\n if (target.exports !== undefined) {\n throw new Error(\n `exports is not supported for archive target: ${targetName}`\n );\n }\n if (target.wasmOpt !== undefined) {\n throw new Error(\n `wasmOpt is not supported for archive target: ${targetName}`\n );\n }\n }\n\n const mergedLinkOptions =\n targetType === 'archive'\n ? []\n : [\n ...ensureArray(common.linkOptions),\n ...ensureArray(target.linkOptions),\n ];\n const mergedLinkDirectives =\n targetType === 'archive'\n ? {}\n : mergeLinkDirectives(common.linkDirectives, target.linkDirectives);\n const mergedExports =\n targetType === 'archive'\n ? []\n : [...ensureArray(common.exports), ...ensureArray(target.exports)];\n const wasmOptEnabled =\n targetType === 'archive'\n ? false\n : resolveWasmOptEnabled(common.wasmOpt, target.wasmOpt);\n const baseCompileOptions = [\n ...ensureArray(common.options),\n ...ensureArray(target.options),\n ];\n const baseIncludeDirs = [\n ...ensureArray(commonIncludeDirs),\n ...ensureArray(target.includeDirs),\n ...importIncludeDirs,\n ];\n const baseDefines = mergeDefines(common.defines, target.defines);\n const sourceGroups = target.sourceGroups ?? [];\n\n const targetEnv = {\n ...envWithDirs,\n TARGET_NAME: targetName,\n };\n const buildEnv = createEnvForBuild(targetEnv, {});\n\n const resolvedOutFile = resolveTargetOutFile(\n targetName,\n target.outFile,\n targetEnv,\n targetType === 'archive' ? libDir : outDir,\n targetType === 'archive' ? 'a' : 'wasm'\n );\n\n const sources = await resolveTargetSources(\n target.sources,\n targetEnv,\n srcDir\n );\n const groupSources: string[][] = sourceGroups.map(() => []);\n const groupSourceSet = new Set<string>();\n for (let index = 0; index < sourceGroups.length; index += 1) {\n const group = sourceGroups[index];\n if (!group) {\n continue;\n }\n const resolved = await resolveSourcesFromPatterns(\n group.sources,\n targetEnv,\n srcDir,\n `sourceGroups[${index}].sources`\n );\n const deduped = dedupeSources(resolved);\n groupSources[index] = deduped;\n for (const source of deduped) {\n groupSourceSet.add(source);\n }\n }\n const baseSources = sources.filter(\n (source) => !groupSourceSet.has(source)\n );\n const groupedSources = groupSources.flat();\n if (baseSources.length + groupedSources.length === 0) {\n throw new Error(`No sources matched for target: ${targetName}`);\n }\n\n const targetBuildDir = resolve(buildRunDir, targetName);\n await rm(targetBuildDir, { recursive: true, force: true });\n await ensureDirectory(targetBuildDir);\n\n const resolvedLinkDirectives =\n targetType === 'archive'\n ? {}\n : resolveLinkDirectives(mergedLinkDirectives, targetEnv);\n const linkDirectiveArgs = buildLinkDirectiveFlags(resolvedLinkDirectives);\n const resolvedLinkOptions =\n targetType === 'archive'\n ? []\n : [\n ...linkDirectiveArgs,\n ...expandArray(mergedLinkOptions, targetEnv, 'linkOptions'),\n ];\n const resolvedExports =\n targetType === 'archive'\n ? []\n : expandArray(mergedExports, targetEnv, 'exports');\n const exportArgs = buildExportFlags(resolvedExports);\n const resolvedWasmOptArgs = wasmOptEnabled\n ? resolveWasmOptArgs(common.wasmOpt, target.wasmOpt, targetEnv)\n : [];\n const baseCompileArgs = buildCompileArgs(\n baseCompileOptions,\n baseIncludeDirs,\n baseDefines,\n targetEnv,\n rootDir\n );\n const groupCompileArgs = sourceGroups.map((group) => {\n const groupOptions = [\n ...baseCompileOptions,\n ...ensureArray(group?.options),\n ];\n const groupIncludeDirs = [\n ...baseIncludeDirs,\n ...ensureArray(group?.includeDirs),\n ];\n const groupDefines = mergeDefines(baseDefines, group?.defines);\n return buildCompileArgs(\n groupOptions,\n groupIncludeDirs,\n groupDefines,\n targetEnv,\n rootDir\n );\n });\n\n //--------------------------------------------------------\n\n const compileSource = async (\n source: string,\n args: CompileArgs,\n groupIndex: number | undefined\n ) => {\n const objectName = toSafeObjectName(rootDir, source, groupIndex);\n const outputObject = resolve(targetBuildDir, `${objectName}.o`);\n const compileArgs = [\n '-c',\n source,\n '-o',\n outputObject,\n ...args.resolvedOptions,\n ...args.includeArgs,\n ...args.defineArgs,\n ];\n const sourcePath = relative(rootDir, source);\n logger.info(`Compiling source: ${sourcePath} --> $tmp/${objectName}.o`);\n logger.debug(`emcc ${compileArgs.join(' ')}`);\n await runCommandWithEnv(\n emccCommand,\n compileArgs,\n rootDir,\n buildEnv,\n emsdkOptions.signal\n );\n return outputObject;\n };\n const buildObjectsSequential = async () => {\n const objectFiles: string[] = [];\n for (const source of baseSources) {\n objectFiles.push(\n await compileSource(source, baseCompileArgs, undefined)\n );\n }\n for (let index = 0; index < groupSources.length; index += 1) {\n const sourcesInGroup = groupSources[index];\n if (!sourcesInGroup) {\n continue;\n }\n const groupArgs = groupCompileArgs[index];\n if (!groupArgs) {\n continue;\n }\n for (const source of sourcesInGroup) {\n objectFiles.push(await compileSource(source, groupArgs, index));\n }\n }\n return objectFiles;\n };\n\n const compileJobs: Array<{\n source: string;\n args: CompileArgs;\n groupIndex: number | undefined;\n }> = [];\n\n // Aggregates base `sources` to the job list\n for (const source of baseSources) {\n compileJobs.push({\n source,\n args: baseCompileArgs,\n groupIndex: undefined,\n });\n }\n\n // Aggregates grouped `sources` to the job list\n for (let index = 0; index < groupSources.length; index += 1) {\n const sourcesInGroup = groupSources[index];\n if (!sourcesInGroup) {\n continue;\n }\n const groupArgs = groupCompileArgs[index];\n if (!groupArgs) {\n continue;\n }\n for (const source of sourcesInGroup) {\n compileJobs.push({ source, args: groupArgs, groupIndex: index });\n }\n }\n\n // Final job stats to logger\n logger.info(\n parallel\n ? `Building target: '${targetName}' [${compileJobs.length} files, in parallel]`\n : `Building target: '${targetName}' [${compileJobs.length} files]`\n );\n\n // Execute the job\n const objectFiles = parallel\n ? await Promise.all(\n compileJobs.map((job) =>\n compileSource(job.source, job.args, job.groupIndex)\n )\n )\n : await buildObjectsSequential();\n\n //--------------------------------------------------------\n\n if (targetType === 'archive') {\n // Execute emsdk archiver\n if (!emarCommand) {\n throw new Error('emar command is required for archive targets.');\n }\n logger.info(`Archiving target: ${targetName}.a`);\n const archiveArgs = ['rcs', resolvedOutFile, ...objectFiles];\n logger.debug(`emar ${archiveArgs.join(' ')}`);\n await runCommandWithEnv(\n emarCommand,\n archiveArgs,\n rootDir,\n buildEnv,\n emsdkOptions.signal\n );\n } else {\n // Execute emsdk linker\n logger.info(`Linking target: ${targetName}.wasm`);\n const linkArgs = [\n ...objectFiles,\n '-o',\n resolvedOutFile,\n ...linkLibDirs.map((dir) => `-L${dir}`),\n ...resolvedLinkOptions,\n ...exportArgs,\n ];\n logger.debug(`emcc ${linkArgs.join(' ')}`);\n await runCommandWithEnv(\n emccCommand,\n linkArgs,\n rootDir,\n buildEnv,\n emsdkOptions.signal\n );\n if (wasmOptEnabled) {\n const wasmOptInput = resolveWasmOptInputFile(\n resolvedOutFile,\n resolvedLinkOptions\n );\n if (!(await pathExists(wasmOptInput))) {\n throw new Error(\n `wasm-opt enabled but wasm binary not found: ${wasmOptInput}`\n );\n }\n const tempOutFile = `${wasmOptInput}.opt`;\n const wasmOptArgs = [\n wasmOptInput,\n '-o',\n tempOutFile,\n ...resolvedWasmOptArgs,\n ];\n const wasmOptCommand = await getWasmOptCommand();\n logger.info(`Optimizing target: ${targetName}.wasm`);\n logger.debug(`wasm-opt ${wasmOptArgs.join(' ')}`);\n await runCommandWithEnv(\n wasmOptCommand,\n wasmOptArgs,\n rootDir,\n buildEnv,\n emsdkOptions.signal\n );\n await rm(wasmOptInput, { force: true });\n await rename(tempOutFile, wasmOptInput);\n }\n }\n\n outFiles[targetName] = resolvedOutFile;\n }\n };\n\n try {\n await buildTargets('archive');\n await buildTargets('wasm');\n if (generatedLoaderFile) {\n const generatedTargets: GeneratedLoaderTarget[] = [];\n const functionNames = new Set<string>();\n for (const [targetName, target] of targetEntries) {\n if (resolveTargetType(target.type) !== 'wasm') {\n continue;\n }\n const outFile = outFiles[targetName];\n if (!outFile) {\n continue;\n }\n const functionName = `load${toPascalCaseIdentifier(targetName)}Wasm`;\n if (functionNames.has(functionName)) {\n throw new Error(\n `Generated loader function name collision: ${functionName}`\n );\n }\n functionNames.add(functionName);\n generatedTargets.push({\n targetName,\n functionName,\n outFile,\n });\n }\n const content = buildGeneratedLoaderContent(\n generatedLoaderFile,\n generatedTargets\n );\n const didWrite = await writeTextIfChanged(generatedLoaderFile, content);\n logger.info(\n didWrite\n ? `Generated loader: ${relative(rootDir, generatedLoaderFile)}`\n : `Generated loader unchanged: ${relative(rootDir, generatedLoaderFile)}`\n );\n resultGeneratedLoaderFile = generatedLoaderFile;\n }\n } finally {\n if (cleanupBuildDir) {\n await rm(buildRunDir, { recursive: true, force: true });\n }\n }\n\n return {\n emsdkRoot,\n outFiles,\n ...(resultGeneratedLoaderFile\n ? { generatedLoaderFile: resultGeneratedLoaderFile }\n : {}),\n };\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,IAAI,uBAAuB;AAC3B,IAAI,oBAAoB;CACvB,SAAS;EACR,OAAO,UAAU;CAClB;AAGD,IAAI,gBAAgB,WAAW;AAC9B,KAAI,kBAAkB,MAAO,QAAO;AACpC,KAAI,OAAO,WAAW,SAAU,QAAO,IAAI,MAAM,OAAO;AACxD,wBAAuB,IAAI,MAAM,oBAAoB;;;;;;;;AAQtD,IAAI,WAAW,QAAQ,aAAa;AACnC,KAAI,CAAC,OAAQ,QAAO;AACpB,KAAI,OAAO,SAAS;AACnB,MAAI;AACH,YAAS,aAAa,OAAO,OAAO,CAAC;WAC7B,OAAO;AACf,WAAQ,KAAK,8BAA8B,MAAM;;AAElD,SAAO;;CAER,IAAI,qBAAqB;AACxB,MAAI,cAAc;GACjB,MAAM,SAAS,OAAO;AACtB,UAAO,oBAAoB,SAAS,aAAa;AACjD,kBAAe,KAAK;AACpB,OAAI;AACH,aAAS,aAAa,OAAO,CAAC;YACtB,OAAO;AACf,YAAQ,KAAK,8BAA8B,MAAM;;;;CAIpD,MAAM,gBAAgB;AACrB,MAAI,cAAc;AACjB,UAAO,oBAAoB,SAAS,aAAa;AACjD,kBAAe,KAAK;;;AAGtB,QAAO,iBAAiB,SAAS,cAAc,EAAE,MAAM,MAAM,CAAC;AAC9D,QAAO;EACN;GACC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M,IAAI,MACR,6CAA6C,eAC9C;AAEH,kBAAc,IAAI,aAAa;AAC/B,qBAAiB,KAAK;KACpB;KACA;KACA;KACD,CAAC;;GAMJ,MAAM,WAAW,MAAM,mBAAmB,qBAJ1B,4BACd,qBACA,iBACD,CACsE;AACvE,UAAO,KACL,WACI,sBAAA,GAAA,KAAA,UAA8B,SAAS,oBAAoB,KAC3D,gCAAA,GAAA,KAAA,UAAwC,SAAS,oBAAoB,GAC1E;AACD,+BAA4B;;WAEtB;AACR,MAAI,gBACF,QAAA,GAAA,YAAA,IAAS,aAAa;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;;AAI3D,QAAO;EACL;EACA;EACA,GAAI,4BACA,EAAE,qBAAqB,2BAA2B,GAClD,EAAE;EACP"}
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { BuildWasmOptions, BuildWasmResult } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build WASM binaries (and optional archives) from C/C++ sources using emsdk.
|
|
14
|
+
*
|
|
15
|
+
* Resolves the SDK via prepareEmsdk, expands build paths, compiles sources,
|
|
16
|
+
* links targets, and returns output paths keyed by target name.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Build options including rule definitions and shared settings.
|
|
19
|
+
* @returns Build result with the resolved SDK root and output file paths.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildWasm: (options: BuildWasmOptions) => Promise<BuildWasmResult>;
|
|
22
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;;;;;;;AAoBA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAQhB,MAAM,SAAS,CAAC;AAs8BjB;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,gBAAgB,KACxB,OAAO,CAAC,eAAe,CA8gBzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export declare const runCommand: (command: string, args: readonly string[], cwd: string, signal: AbortSignal | undefined) => Promise<void>;
|
|
12
|
+
export declare const runCommandWithEnv: (command: string, args: readonly string[], cwd: string, env: NodeJS.ProcessEnv, signal: AbortSignal | undefined) => Promise<void>;
|
|
13
|
+
export declare const runCommandCapture: (command: string, args: readonly string[], cwd: string, signal: AbortSignal | undefined) => Promise<Buffer<ArrayBufferLike>>;
|
|
14
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":";;;;;;;;;AAeA,eAAO,MAAM,UAAU,GACrB,SAAS,MAAM,EACf,MAAM,SAAS,MAAM,EAAE,EACvB,KAAK,MAAM,EACX,QAAQ,WAAW,GAAG,SAAS,kBA8ChC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,MAAM,SAAS,MAAM,EAAE,EACvB,KAAK,MAAM,EACX,KAAK,MAAM,CAAC,UAAU,EACtB,QAAQ,WAAW,GAAG,SAAS,kBA+ChC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,MAAM,SAAS,MAAM,EAAE,EACvB,KAAK,MAAM,EACX,QAAQ,WAAW,GAAG,SAAS,qCAyDhC,CAAC"}
|
package/dist/emsdk.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { PrepareEmsdkOptions } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Prepare the Emscripten SDK in the local cache and return the SDK root path.
|
|
14
|
+
*
|
|
15
|
+
* Clones the emsdk repository if needed, installs the requested version,
|
|
16
|
+
* and activates it in the cache directory.
|
|
17
|
+
*
|
|
18
|
+
* @param options - SDK preparation options.
|
|
19
|
+
* @returns Absolute path to the prepared SDK root.
|
|
20
|
+
*/
|
|
21
|
+
export declare const prepareEmsdk: (options: PrepareEmsdkOptions) => Promise<string>;
|
|
22
|
+
//# sourceMappingURL=emsdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emsdk.d.ts","sourceRoot":"","sources":["../src/emsdk.ts"],"names":[],"mappings":";;;;;;;;;AAYA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AA8EnD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,mBAAmB,KAC3B,OAAO,CAAC,MAAM,CA+DhB,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Logger } from './types.js';
|
|
12
|
+
export declare const loadEmsdkEnv: (emsdkRoot: string, logger: Logger, signal: AbortSignal | undefined) => Promise<Record<string, string>>;
|
|
13
|
+
export declare const resolveEmccCommand: (env: Record<string, string>, emsdkRoot: string) => Promise<string>;
|
|
14
|
+
export declare const resolveEmarCommand: (env: Record<string, string>, emsdkRoot: string) => Promise<string>;
|
|
15
|
+
export declare const resolveWasmOptCommand: (env: Record<string, string>, emsdkRoot: string) => Promise<string>;
|
|
16
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;;;;;;;;AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AA2BtC,eAAO,MAAM,eAAY,GACvB,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,QAAQ,WAAW,GAAG,SAAS,oCAoBhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,WAAW,MAAM,oBAgBlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,WAAW,MAAM,oBAgBlB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,WAAW,MAAM,oBAiBlB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export declare const pathExists: (targetPath: string) => Promise<boolean>;
|
|
12
|
+
export declare const ensureDirectory: (targetPath: string) => Promise<void>;
|
|
13
|
+
//# sourceMappingURL=fs-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-utils.d.ts","sourceRoot":"","sources":["../src/fs-utils.ts"],"names":[],"mappings":";;;;;;;;;AASA,eAAO,MAAM,UAAU,GAAU,YAAY,MAAM,qBAOlD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,YAAY,MAAM,kBAEvD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: emsdk-env
|
|
3
|
+
* version: 0.11.0
|
|
4
|
+
* description: Emscripten environment builder
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/emsdk-env
|
|
8
|
+
* git.commit.hash: 0cf3fec6df406458fa2cf19fe561648e1ad4e369
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export declare const name = "emsdk-env";
|
|
12
|
+
export declare const version = "0.11.0";
|
|
13
|
+
export declare const description = "Emscripten environment builder";
|
|
14
|
+
export declare const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
15
|
+
export declare const license = "MIT";
|
|
16
|
+
export declare const repository_url = "https://github.com/kekyo/emsdk-env";
|
|
17
|
+
export declare const git_commit_hash = "0cf3fec6df406458fa2cf19fe561648e1ad4e369";
|
|
18
|
+
//# sourceMappingURL=packageMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageMetadata.d.ts","sourceRoot":"","sources":["../../src/generated/packageMetadata.ts"],"names":[],"mappings":";;;;;;;;;AAIA,eAAO,MAAM,IAAI,cAAc,CAAC;AAChC,eAAO,MAAM,OAAO,WAAW,CAAC;AAChC,eAAO,MAAM,WAAW,mCAAmC,CAAC;AAC5D,eAAO,MAAM,MAAM,uCAAuC,CAAC;AAC3D,eAAO,MAAM,OAAO,QAAQ,CAAC;AAC7B,eAAO,MAAM,cAAc,uCAAuC,CAAC;AACnE,eAAO,MAAM,eAAe,6CAA6C,CAAC"}
|