@dual-os/adyen-api 0.0.0-stage → 6.0.4
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/LICENSE +4 -0
- package/Runner.js +5537 -0
- package/Runner.js.map +59 -0
- package/bundle-inventory.json +1 -0
- package/dist/_virtual/_rolldown/runtime.js +10 -0
- package/dist/_virtual/_rolldown/runtime.js.map +9 -0
- package/dist/auth.d.ts +39 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +17 -0
- package/dist/auth.js.map +9 -0
- package/dist/generated/http.d.ts +81 -0
- package/dist/generated/http.d.ts.map +1 -0
- package/dist/generated/http.js +64 -0
- package/dist/generated/http.js.map +9 -0
- package/dist/generated/operations.d.ts +15588 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +3946 -0
- package/dist/generated/operations.js.map +9 -0
- package/dist/generated/plugin.d.ts +1540 -0
- package/dist/generated/plugin.d.ts.map +1 -0
- package/dist/generated/plugin.js +5111 -0
- package/dist/generated/plugin.js.map +10 -0
- package/dist/triggers.d.ts +303 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.js +17 -0
- package/dist/triggers.js.map +9 -0
- package/dual-plugin.json +1 -0
- package/licenses/@dual-os_sdk@0.9.0/LICENSE +4 -0
- package/licenses/@effect_platform-node-shared@4.1.2/LICENSE +21 -0
- package/licenses/@effect_platform-node@4.1.2/LICENSE +21 -0
- package/licenses/effect@4.1.2/LICENSE +21 -0
- package/package.json +1 -6
- package/plugin-2jdfj02n.js +18 -0
- package/plugin-2jdfj02n.js.map +10 -0
- package/plugin-48zbqzh4.js +55052 -0
- package/plugin-48zbqzh4.js.map +10 -0
- package/plugin-ctytbs1j.js +250 -0
- package/plugin-ctytbs1j.js.map +10 -0
- package/plugin-pbdgaxvn.js +1303 -0
- package/plugin-pbdgaxvn.js.map +18 -0
- package/plugin-vnx323vz.js +19085 -0
- package/plugin-vnx323vz.js.map +158 -0
- package/plugin-z4svmw67.js +62 -0
- package/plugin-z4svmw67.js.map +10 -0
- package/plugin.json +174 -0
- package/README.md +0 -3
package/Runner.js.map
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/ulid.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/uuid.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/WebCrypto.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/SecureRandom.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/BigInt.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/ByteSize.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/CryptoError.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/chacha.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/webCrypto.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/key.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Aead.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Cipher.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/asymmetric.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/KeyAgreement.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Digest.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Mac.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/KeyWrap.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Signature.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Brand.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/glob.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/PlatformError.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Sink.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/rcRef.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/RcRef.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/FileSystem.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Path.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/ManagedRuntime.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Stdio.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Terminal.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Kdf.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/process/ChildProcessSpawner.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/process/CommandLine.js", "../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/process/ChildProcess.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/internal/nodeChildProcessSpawner.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/internal/utils.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeSink.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/internal/stream.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeStream.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js", "../../../../node_modules/.bun/@effect+platform-node@4.1.2+22a1c27d4b1c9267/node_modules/@effect/platform-node/dist/NodeFileSystem.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodePath.js", "../../../../node_modules/.bun/@effect+platform-node@4.1.2+22a1c27d4b1c9267/node_modules/@effect/platform-node/dist/NodePath.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeStdio.js", "../../../../node_modules/.bun/@effect+platform-node@4.1.2+22a1c27d4b1c9267/node_modules/@effect/platform-node/dist/NodeStdio.js", "../../../../node_modules/.bun/@effect+platform-node-shared@4.1.2+edf248c88a527e3e/node_modules/@effect/platform-node-shared/dist/NodeTerminal.js", "../../../../node_modules/.bun/@effect+platform-node@4.1.2+22a1c27d4b1c9267/node_modules/@effect/platform-node/dist/NodeTerminal.js", "../../../../node_modules/.bun/@effect+platform-node@4.1.2+22a1c27d4b1c9267/node_modules/@effect/platform-node/dist/NodeServices.js", "../../../../node_modules/.bun/@dual-os+sdk@0.9.0+a827849ded09603e/node_modules/@dual-os/sdk/dist/Runner.js"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"const maxTimestamp = 2 ** 48 - 1;\nconst base32Chars = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\n/** @internal */\nexport const ulidString = (timestampMillis, bytes) => {\n if (bytes.length !== 10) {\n throw new Error(`ULID randomness must be exactly 10 bytes, received ${bytes.length}`);\n }\n const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxTimestamp);\n let out = \"\";\n for (let shift = 45; shift >= 0; shift -= 5) {\n // Take the low 5 bits and map NaN to zero, matching UUIDv7's byte encoding.\n out += base32Chars[Math.floor(timestamp / 2 ** shift) & 0x1f];\n }\n let accumulator = 0;\n let bits = 0;\n for (const byte of bytes) {\n accumulator = accumulator << 8 | byte;\n bits += 8;\n while (bits >= 5) {\n bits -= 5;\n out += base32Chars[accumulator >>> bits & 0x1f];\n }\n accumulator &= (1 << bits) - 1;\n }\n return out;\n};\n/**\n * Makes a ULID generator in the ULID spec's monotonic mode: within a\n * millisecond, or when the clock moves back, the 80-bit random part of the last\n * ULID is incremented. The ordering ends at the maximum timestamp, 2^48 − 1 ms,\n * which overflow cannot advance. `randomBytes` is only called for fresh\n * randomness.\n *\n * @internal\n */\nexport const makeMonotonic = () => {\n let lastTimestamp = -1;\n const random = new Uint8Array(10);\n return (timestampMillis, randomBytes) => {\n const timestamp = timestampMillis >= 0 ? Math.min(Math.trunc(timestampMillis), maxTimestamp) : 0;\n if (timestamp > lastTimestamp) {\n lastTimestamp = timestamp;\n random.set(randomBytes());\n } else if (!increment(random)) {\n lastTimestamp = Math.min(lastTimestamp + 1, maxTimestamp);\n random.set(randomBytes());\n }\n return ulidString(lastTimestamp, random);\n };\n};\n// Returns false when the bytes overflow, leaving them all zero.\nconst increment = bytes => {\n for (let i = bytes.length - 1; i >= 0; i--) {\n if (bytes[i] !== 0xff) {\n bytes[i]++;\n return true;\n }\n bytes[i] = 0;\n }\n return false;\n};\n/**\n * The ULID ordering state shared by every `Date.now()` caller in the realm.\n *\n * @internal\n */\nexport const monotonic = /*#__PURE__*/makeMonotonic();\n//# sourceMappingURL=ulid.js.map",
|
|
6
|
+
"const hex = /*#__PURE__*/Array.from({\n length: 256\n}, (_, byte) => byte.toString(16).padStart(2, \"0\"));\n/** @internal */\nexport const stringify = bytes => {\n if (bytes.length < 16) {\n return [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)].map(segment => Array.from(segment, byte => hex[byte]).join(\"\")).join(\"-\");\n }\n return hex[bytes[0]] + hex[bytes[1]] + hex[bytes[2]] + hex[bytes[3]] + \"-\" + hex[bytes[4]] + hex[bytes[5]] + \"-\" + hex[bytes[6]] + hex[bytes[7]] + \"-\" + hex[bytes[8]] + hex[bytes[9]] + \"-\" + hex[bytes[10]] + hex[bytes[11]] + hex[bytes[12]] + hex[bytes[13]] + hex[bytes[14]] + hex[bytes[15]];\n};\n/** @internal */\nexport const v4Bytes = bytes => {\n bytes[6] = bytes[6] & 0x0f | 0x40;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n return bytes;\n};\n/** @internal */\nexport const v4String = bytes => stringify(v4Bytes(bytes));\nconst maxV7Timestamp = 2 ** 48 - 1;\n/** @internal */\nexport const v7Bytes = (timestampMillis, bytes) => {\n const timestamp = Math.min(Math.max(0, Math.trunc(timestampMillis)), maxV7Timestamp);\n bytes[0] = Math.floor(timestamp / 2 ** 40);\n bytes[1] = Math.floor(timestamp / 2 ** 32) & 0xff;\n bytes[2] = Math.floor(timestamp / 2 ** 24) & 0xff;\n bytes[3] = Math.floor(timestamp / 2 ** 16) & 0xff;\n bytes[4] = Math.floor(timestamp / 2 ** 8) & 0xff;\n bytes[5] = timestamp & 0xff;\n bytes[6] = bytes[6] & 0x0f | 0x70;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n return bytes;\n};\nconst clampV7Timestamp = timestampMillis => timestampMillis >= 0 ? Math.min(Math.trunc(timestampMillis), maxV7Timestamp) : 0;\nconst maxV7Counter = 2 ** 42 - 1;\n/**\n * Makes a UUIDv7 generator that orders the UUIDs it returns, following RFC\n * 9562 §6.2 Method 1. A 42-bit counter fills the 12 bits of `rand_a` and the\n * top 30 bits of `rand_b`; the last 32 bits stay random. The ordering ends at\n * the maximum timestamp, 2^48 − 1 ms, which counter overflow cannot advance.\n *\n * @internal\n */\nexport const makeV7Monotonic = () => {\n let lastTimestamp = -1;\n let counter = 0;\n return (timestampMillis, bytes) => {\n const timestamp = clampV7Timestamp(timestampMillis);\n if (timestamp > lastTimestamp) {\n lastTimestamp = timestamp;\n counter = seedV7Counter(bytes);\n } else if (counter < maxV7Counter) {\n // The clock stalled or moved back, so keep the last timestamp.\n counter++;\n } else {\n lastTimestamp = Math.min(lastTimestamp + 1, maxV7Timestamp);\n counter = seedV7Counter(bytes);\n }\n v7Bytes(lastTimestamp, bytes);\n const high = Math.floor(counter / 2 ** 30);\n const low = counter - high * 2 ** 30;\n bytes[6] = 0x70 | high >>> 8;\n bytes[7] = high & 0xff;\n bytes[8] = 0x80 | low >>> 24;\n bytes[9] = low >>> 16 & 0xff;\n bytes[10] = low >>> 8 & 0xff;\n bytes[11] = low & 0xff;\n return bytes;\n };\n};\n// Clears the counter's top bit, so a millisecond has at least 2^41 increments\n// before it overflows.\nconst seedV7Counter = bytes => ((bytes[6] & 0x07) << 8 | bytes[7]) * 2 ** 30 + ((bytes[8] & 0x3f) << 24 | bytes[9] << 16 | bytes[10] << 8 | bytes[11]);\n/**\n * The UUIDv7 ordering state shared by every `Date.now()` or `Clock` caller in\n * the realm that has no `SecureRandom` instance of its own.\n *\n * @internal\n */\nexport const v7Monotonic = /*#__PURE__*/makeV7Monotonic();\n//# sourceMappingURL=uuid.js.map",
|
|
7
|
+
"/**\n * The WebCrypto `Crypto` object that the `effect/crypto` modules run on.\n *\n * The `layerWebCrypto` layers of the family modules, such as\n * `Digest.layerWebCrypto`, and key functions that touch\n * `crypto.subtle`, such as `Mac.toBytes`, read the {@link WebCrypto}\n * reference. It defaults to `globalThis.crypto`. Provide {@link layer} to run\n * them on a polyfill, a worker's object, or a test double.\n *\n * **Gotchas**\n *\n * Browsers expose `crypto.subtle` only in secure contexts. Elsewhere, every\n * operation that needs it dies with \"crypto.subtle is unavailable\". Layers\n * still build, and `SecureRandom` and the pure TypeScript algorithms, such as\n * MD5, keep working.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Layer from \"../Layer.js\";\n/**\n * Reference to the WebCrypto `Crypto` object, defaulting to\n * `globalThis.crypto`.\n *\n * @see {@link layer} for replacing it\n *\n * @stability unstable\n * @category references\n * @since 4.0.0\n */\nexport const WebCrypto = /*#__PURE__*/Context.Reference(\"effect/crypto/WebCrypto\", {\n defaultValue: () => globalThis.crypto\n});\n/**\n * Layer that sets the {@link WebCrypto} reference.\n *\n * **When to use**\n *\n * Use to run the `effect/crypto` modules on a polyfill, a worker's `Crypto`\n * object, or a test double.\n *\n * **Example** (Using a `Crypto` polyfill)\n *\n * ```ts import.meta.vitest\n * import { Effect } from \"effect\"\n * import { Digest, WebCrypto } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const digest = yield* Digest.Digest\n * return yield* digest.digestHex(Digest.sha256, new TextEncoder().encode(\"abc\"))\n * }).pipe(Effect.provide(Digest.layerWebCrypto))\n *\n * const hex = await Effect.runPromise(program.pipe(Effect.provide(WebCrypto.layer(globalThis.crypto))))\n * hex.length // => 64\n * ```\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = crypto => Layer.succeed(WebCrypto, crypto);\n//# sourceMappingURL=WebCrypto.js.map",
|
|
8
|
+
"/**\n * Cryptographically secure randomness: random bytes, uniform integers,\n * shuffles, UUIDv4, UUIDv7, and ULIDs.\n *\n * The {@link SecureRandom} service is built from one `randomBytes` primitive\n * with {@link make}. {@link layerWebCrypto} draws from `getRandomValues` on\n * the `WebCrypto` reference. The `*Unsafe` functions draw synchronously from\n * `globalThis.crypto` for code that cannot use a service, such as constructors\n * and model defaults.\n *\n * Every operation has a `never` error channel. A bad size or an empty range is\n * a defect.\n *\n * **Gotchas**\n *\n * There are no float, boolean, or full-range integer helpers. Insecure random\n * numbers belong to `effect/Random`, and a secure bit is `randomBytes(1)`.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Ulid from \"../internal/ulid.js\";\nimport * as Uuid from \"../internal/uuid.js\";\nimport * as Layer from \"../Layer.js\";\nimport { WebCrypto } from \"./WebCrypto.js\";\n/**\n * Service that generates cryptographically secure random values.\n *\n * **Details**\n *\n * Every operation is derived from `randomBytes`. See {@link make}.\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class SecureRandom extends /*#__PURE__*/Context.Service()(\"effect/crypto/SecureRandom\") {}\nconst checkSize = size => {\n if (!Number.isSafeInteger(size) || size < 0) {\n throw new RangeError(\"size must be a non-negative safe integer\");\n }\n};\nconst readUint53 = bytes => (bytes[0] & 0x1f) * 2 ** 48 + bytes[1] * 2 ** 40 + bytes[2] * 2 ** 32 + bytes[3] * 2 ** 24 + bytes[4] * 2 ** 16 + bytes[5] * 2 ** 8 + bytes[6];\n// Draws an integer by rejection sampling over 53-bit (or, for ranges wider than\n// 2^53, 54-bit) draws, so every integer in the range has the same probability.\nconst intBetweenUnsafe = (min, max, halfOpen, draw) => {\n const minInt = Math.ceil(min);\n const maxInt = Math.floor(max);\n if (!Number.isSafeInteger(minInt) || !Number.isSafeInteger(maxInt)) {\n throw new RangeError(\"bounds must round to safe integers\");\n }\n if (maxInt - minInt < Number.MAX_SAFE_INTEGER) {\n // Every intermediate stays below 2^53, and `%` is exact, so the divisions\n // below are exact without BigInt.\n const count = maxInt - minInt + (halfOpen ? 0 : 1);\n if (count <= 0) {\n throw new RangeError(\"range must contain at least one integer\");\n }\n // `+ 0` turns `Math.ceil` of a value in (-1, 0) into 0 instead of -0.\n if (count === 1) return minInt + 0;\n const bucketSize = (2 ** 53 - 2 ** 53 % count) / count;\n const limit = bucketSize * count;\n while (true) {\n const value = readUint53(draw());\n if (value < limit) return minInt + (value - value % bucketSize) / bucketSize;\n }\n }\n // BigInt keeps every integer distinct when the range is wider than 2^53.\n const lower = BigInt(minInt);\n const count = BigInt(maxInt) - lower + (halfOpen ? BigInt(0) : BigInt(1));\n const wide = count > BigInt(1) << BigInt(53);\n const bucketSize = (wide ? BigInt(1) << BigInt(54) : BigInt(1) << BigInt(53)) / count;\n const limit = bucketSize * count;\n while (true) {\n const bytes = draw();\n const value = BigInt(readUint53(bytes)) + (wide && (bytes[0] & 0x20) !== 0 ? BigInt(1) << BigInt(53) : BigInt(0));\n if (value < limit) return Number(lower + value / bucketSize);\n }\n};\nconst makeUuid = (bytes, randomBytes, format) => {\n const uuid = bytes(randomBytes(16));\n return format === \"bytes\" ? uuid : Uuid.stringify(uuid);\n};\n/**\n * Creates a `SecureRandom` service from a secure byte source.\n *\n * **When to use**\n *\n * Use to build the service for a platform integration, a custom runtime, or a\n * seeded test double.\n *\n * **Details**\n *\n * Every operation is derived from `randomBytes`. Sizes are checked before it\n * is called, and an exception it throws is a defect. Each service orders its\n * own UUIDv7s and ULIDs, independently of other services and of the\n * `*Unsafe` functions.\n *\n * **Gotchas**\n *\n * `randomBytes` must return a fresh array of exactly `size` secure random\n * bytes. UUID formatting mutates the returned array.\n *\n * **Example** (Creating a SecureRandom service)\n *\n * ```ts import.meta.vitest\n * import { Effect } from \"effect\"\n * import { SecureRandom } from \"effect/crypto\"\n *\n * const random = SecureRandom.make((size) => globalThis.crypto.getRandomValues(new Uint8Array(size)))\n *\n * const bytes = await Effect.runPromise(random.randomBytes(4))\n * bytes.length // => 4\n * ```\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = randomBytes => {\n const randomBytesChecked = size => {\n checkSize(size);\n return randomBytes(size);\n };\n const draw = () => randomBytes(7);\n const uuidV7 = Uuid.makeV7Monotonic();\n const ulid = Ulid.makeMonotonic();\n const ulidRandomBytes = () => randomBytes(10);\n return {\n randomBytes: size => Effect.sync(() => randomBytesChecked(size)),\n intBetween: (min, max, options) => Effect.sync(() => intBetweenUnsafe(min, max, options?.halfOpen ?? false, draw)),\n shuffle: elements => Effect.sync(() => {\n const buffer = Array.from(elements);\n for (let i = buffer.length - 1; i >= 1; i--) {\n const index = intBetweenUnsafe(0, i, false, draw);\n const value = buffer[i];\n buffer[i] = buffer[index];\n buffer[index] = value;\n }\n return buffer;\n }),\n uuidV4: options => Effect.sync(() => makeUuid(Uuid.v4Bytes, randomBytes, options?.format)),\n uuidV7: options => Effect.clockWith(clock => Effect.sync(() => makeUuid(bytes => uuidV7(clock.currentTimeMillisUnsafe(), bytes), randomBytes, options?.format))),\n ulid: Effect.clockWith(clock => Effect.sync(() => ulid(clock.currentTimeMillisUnsafe(), ulidRandomBytes)))\n };\n};\n// `getRandomValues` throws a `QuotaExceededError` above 65,536 bytes.\nconst fillRandom = (crypto, size) => {\n const bytes = new Uint8Array(size);\n for (let offset = 0; offset < size; offset += 65_536) {\n crypto.getRandomValues(bytes.subarray(offset, offset + 65_536));\n }\n return bytes;\n};\n/**\n * Layer that provides `SecureRandom` from `getRandomValues` on the `WebCrypto`\n * reference.\n *\n * **Details**\n *\n * Requests above the 65,536-byte `getRandomValues` limit are filled in chunks.\n * Only `getRandomValues` is needed, so the layer also works in insecure browser\n * contexts, which have no `crypto.subtle`.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(SecureRandom, /*#__PURE__*/WebCrypto.use(crypto => Effect.succeed(make(size => fillRandom(crypto, size)))));\n/**\n * Synchronously generates `size` cryptographically secure random bytes from\n * `globalThis.crypto`.\n *\n * **When to use**\n *\n * Use when a service cannot be read, as in constructors and model defaults.\n * Elsewhere, use the `SecureRandom` service.\n *\n * **Gotchas**\n *\n * Reads `globalThis.crypto` directly, so neither the `WebCrypto` reference nor\n * a mocked `SecureRandom` service affects it. A negative or non-integer size\n * throws a `RangeError`.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const randomBytesUnsafe = size => {\n checkSize(size);\n return fillRandom(globalThis.crypto, size);\n};\n/**\n * Synchronously generates a UUIDv4 from `globalThis.crypto`, as a lowercase\n * hyphenated string or, with `format: \"bytes\"`, the 16 UUID bytes.\n *\n * **Gotchas**\n *\n * Reads `globalThis.crypto` directly, so neither the `WebCrypto` reference nor\n * a mocked `SecureRandom` service affects it.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const uuidV4Unsafe = options => makeUuid(Uuid.v4Bytes, randomBytesUnsafe, options?.format);\n/**\n * Synchronously generates a UUIDv7 from `Date.now()` and `globalThis.crypto`,\n * as a lowercase hyphenated string or, with `format: \"bytes\"`, the 16 UUID\n * bytes.\n *\n * **Details**\n *\n * Below the maximum timestamp, every UUIDv7 generated in this JS realm\n * (process or worker) sorts after the previous one, as a string and as bytes,\n * using the counter described on the `SecureRandom` service's `uuidV7`. The\n * ordering is shared with `Model.UuidV7WithGenerate`, and does not hold across\n * processes or workers. Consecutive UUIDv7s reveal their\n * generation order, so never use them as secrets.\n *\n * **Gotchas**\n *\n * Reads `Date.now()` rather than the `Clock`, and `globalThis.crypto` rather\n * than the `WebCrypto` reference. A timestamp can run slightly ahead of\n * `Date.now()` when the clock moves back or the counter overflows.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const uuidV7Unsafe = options => makeUuid(bytes => Uuid.v7Monotonic(Date.now(), bytes), randomBytesUnsafe, options?.format);\n/**\n * Synchronously generates a ULID from `Date.now()` and `globalThis.crypto`.\n *\n * **Details**\n *\n * Below the maximum timestamp, every ULID generated in this JS realm (process\n * or worker) sorts after the previous one, using the monotonic mode described\n * on the `SecureRandom` service's `ulid`. The ordering does not hold across\n * processes or workers. Consecutive ULIDs reveal their generation order, so\n * never use them as secrets.\n *\n * **Gotchas**\n *\n * Reads `Date.now()` rather than the `Clock`, and `globalThis.crypto` rather\n * than the `WebCrypto` reference. A timestamp can run slightly ahead of\n * `Date.now()` when the clock moves back or the random part overflows.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const ulidUnsafe = () => Ulid.monotonic(Date.now(), ulidRandomBytesUnsafe);\nconst ulidRandomBytesUnsafe = () => randomBytesUnsafe(10);\n//# sourceMappingURL=SecureRandom.js.map",
|
|
9
|
+
"/**\n * Works with JavaScript `bigint` values.\n *\n * This module exposes the native `BigInt` constructor together with helpers for\n * checking, arithmetic, comparison, range checks, safe parsing and conversions\n * that return `Option`, integer square roots, aggregation, ordering,\n * equivalence, reducers, and combiners.\n *\n * @stability stable\n * @since 2.0.0\n */\nimport * as Combiner from \"./Combiner.js\";\nimport * as Equ from \"./Equivalence.js\";\nimport { dual } from \"./Function.js\";\nimport * as Option from \"./Option.js\";\nimport * as order from \"./Order.js\";\nimport * as predicate from \"./Predicate.js\";\nimport * as Reducer from \"./Reducer.js\";\n/**\n * Exposes the global bigint constructor for JavaScript bigint coercion.\n *\n * **When to use**\n *\n * Use to access native JavaScript bigint constructor coercion from the Effect\n * module namespace.\n *\n * **Gotchas**\n *\n * This follows native `BigInt` coercion rules. It throws for invalid strings or\n * non-integral numbers, and whitespace-only strings coerce to `0n`.\n *\n * @see {@link fromString} for parsing strings into an `Option`\n * @see {@link fromNumber} for converting safe integers into an `Option`\n *\n * **Example** (Constructing bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.BigInt(123) // => 123n\n * BigInt.BigInt(\"456\") // => 456n\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const BigInt = globalThis.BigInt;\nconst bigint0 = /*#__PURE__*/BigInt(0);\nconst bigint1 = /*#__PURE__*/BigInt(1);\nconst bigint2 = /*#__PURE__*/BigInt(2);\n/**\n * Checks whether a value is a `bigint`.\n *\n * **When to use**\n *\n * Use to validate unknown input and narrow it to `bigint`.\n *\n * **Example** (Checking for bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.isBigInt(1n) // => true\n * BigInt.isBigInt(1) // => false\n * ```\n *\n * @stability stable\n * @category guards\n * @since 2.0.0\n */\nexport const isBigInt = predicate.isBigInt;\n/**\n * Provides an addition operation on `bigint`s.\n *\n * **When to use**\n *\n * Use when you need a binary addition function for piping or higher-order APIs\n * instead of the infix addition operator.\n *\n * **Example** (Adding bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.sum(2n, 3n) // => 5n\n * ```\n *\n * @see {@link sumAll} for summing an iterable of `bigint` values\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const sum = /*#__PURE__*/dual(2, (self, that) => self + that);\n/**\n * Provides a multiplication operation on `bigint`s.\n *\n * **When to use**\n *\n * Use to multiply two `bigint` values.\n *\n * **Example** (Multiplying bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.multiply(2n, 3n) // => 6n\n * ```\n *\n * @see {@link multiplyAll} for multiplying an iterable of `bigint` values\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const multiply = /*#__PURE__*/dual(2, (self, that) => self * that);\n/**\n * Provides a subtraction operation on `bigint`s.\n *\n * **When to use**\n *\n * Use to subtract one `bigint` value from another.\n *\n * **Example** (Subtracting bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.subtract(2n, 3n) // => -1n\n * ```\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const subtract = /*#__PURE__*/dual(2, (self, that) => self - that);\n/**\n * Divides one `bigint` by another safely.\n *\n * **When to use**\n *\n * Use to divide `bigint` values while representing division by zero as\n * `Option.none`.\n *\n * **Details**\n *\n * Uses JavaScript `bigint` division, so non-exact quotients are truncated\n * toward zero. Returns `Option.none()` when the divisor is `0n`.\n *\n * **Example** (Dividing bigints safely)\n *\n * ```ts import.meta.vitest\n * import { BigInt, Option } from \"effect\"\n *\n * BigInt.divide(6n, 3n) // => Option.some(2n)\n * BigInt.divide(6n, 0n) // => Option.none()\n * ```\n *\n * @see {@link divideUnsafe} for division that throws when the divisor is `0n`\n * @see {@link remainder} for the JavaScript remainder operation\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const divide = /*#__PURE__*/dual(2, (self, that) => that === bigint0 ? Option.none() : Option.some(self / that));\n/**\n * Divides one `bigint` by another, throwing if the divisor is zero.\n *\n * **When to use**\n *\n * Use to divide `bigint` values where the divisor is known to be non-zero and\n * division by zero should be a thrown exception.\n *\n * **Details**\n *\n * Uses JavaScript `bigint` division, so non-exact quotients are truncated\n * toward zero.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` when the divisor is `0n`.\n *\n * **Example** (Dividing bigints unsafely)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.divideUnsafe(6n, 3n) // => 2n\n * BigInt.divideUnsafe(6n, 4n) // => 1n\n * ```\n *\n * @see {@link divide} for division that returns `Option.none` when the divisor is `0n`\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const divideUnsafe = /*#__PURE__*/dual(2, (self, that) => self / that);\n/**\n * Returns the result of adding `1n` to a `bigint`.\n *\n * **When to use**\n *\n * Use to increment a `bigint` counter by one.\n *\n * **Example** (Incrementing a bigint)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.increment(2n) // => 3n\n * ```\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const increment = n => n + bigint1;\n/**\n * Returns the result of subtracting `1n` from a `bigint`.\n *\n * **When to use**\n *\n * Use to decrement a `bigint` counter by one.\n *\n * **Example** (Decrementing a bigint)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.decrement(3n) // => 2n\n * ```\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const decrement = n => n - bigint1;\n/**\n * Provides an `Order` instance for `bigint` that allows comparing and sorting BigInt values.\n *\n * **When to use**\n *\n * Use when you need to sort or compare bigint values through APIs that accept\n * an ordering instance.\n *\n * **Example** (Comparing bigints with Order)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * const a = 123n\n * const b = 456n\n * const c = 123n\n *\n * BigInt.Order(a, b) // => -1\n * BigInt.Order(b, a) // => 1\n * BigInt.Order(a, c) // => 0\n * ```\n *\n * @stability stable\n * @category instances\n * @since 2.0.0\n */\nexport const Order = order.BigInt;\n/**\n * Equivalence instance for bigints using strict equality (`===`).\n *\n * **When to use**\n *\n * Use when checking bigint equality through APIs that accept an equivalence\n * relation.\n *\n * **Example** (Comparing bigints for equivalence)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.Equivalence(1n, 1n) // => true\n * BigInt.Equivalence(1n, 2n) // => false\n * ```\n *\n * @stability stable\n * @category instances\n * @since 2.0.0\n */\nexport const Equivalence = Equ.BigInt;\n/**\n * Returns `true` if the first argument is less than the second, otherwise `false`.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is strictly less than another.\n *\n * **Example** (Checking less-than comparisons)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.isLessThan(2n, 3n) // => true\n * BigInt.isLessThan(3n, 3n) // => false\n * BigInt.isLessThan(4n, 3n) // => false\n * ```\n *\n * @stability stable\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThan = /*#__PURE__*/order.isLessThan(Order);\n/**\n * Returns a function that checks if a given `bigint` is less than or equal to the provided one.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is less than or equal to another.\n *\n * **Example** (Checking less-than-or-equal comparisons)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.isLessThanOrEqualTo(2n, 3n) // => true\n * BigInt.isLessThanOrEqualTo(3n, 3n) // => true\n * BigInt.isLessThanOrEqualTo(4n, 3n) // => false\n * ```\n *\n * @stability stable\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThanOrEqualTo = /*#__PURE__*/order.isLessThanOrEqualTo(Order);\n/**\n * Returns `true` if the first argument is greater than the second, otherwise `false`.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is strictly greater than another.\n *\n * **Example** (Checking greater-than comparisons)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.isGreaterThan(2n, 3n) // => false\n * BigInt.isGreaterThan(3n, 3n) // => false\n * BigInt.isGreaterThan(4n, 3n) // => true\n * ```\n *\n * @stability stable\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThan = /*#__PURE__*/order.isGreaterThan(Order);\n/**\n * Returns a function that checks if a given `bigint` is greater than or equal to the provided one.\n *\n * **When to use**\n *\n * Use to test whether one `bigint` is greater than or equal to another.\n *\n * **Example** (Checking greater-than-or-equal comparisons)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.isGreaterThanOrEqualTo(2n, 3n) // => false\n * BigInt.isGreaterThanOrEqualTo(3n, 3n) // => true\n * BigInt.isGreaterThanOrEqualTo(4n, 3n) // => true\n * ```\n *\n * @stability stable\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThanOrEqualTo = /*#__PURE__*/order.isGreaterThanOrEqualTo(Order);\n/**\n * Checks whether a `bigint` is between a `minimum` and `maximum` value (inclusive).\n *\n * **When to use**\n *\n * Use to test whether a `bigint` falls inside an inclusive range.\n *\n * **Example** (Checking whether a bigint is within bounds)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * const between = BigInt.between({ minimum: 0n, maximum: 5n })\n *\n * between(3n) // => true\n * between(-1n) // => false\n * between(6n) // => false\n * ```\n *\n * @see {@link clamp} for forcing a `bigint` into an inclusive range\n *\n * @stability stable\n * @category predicates\n * @since 2.0.0\n */\nexport const between = /*#__PURE__*/order.isBetween(Order);\n/**\n * Restricts the given `bigint` to be within the range specified by the `minimum` and `maximum` values.\n *\n * **When to use**\n *\n * Use to force a `bigint` into an inclusive range.\n *\n * **Details**\n *\n * If the `bigint` is less than the minimum, the function returns the minimum.\n * If the `bigint` is greater than the maximum, the function returns the\n * maximum. Otherwise, it returns the original `bigint`.\n *\n * **Example** (Clamping a bigint to bounds)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * const clamp = BigInt.clamp({ minimum: 1n, maximum: 5n })\n *\n * clamp(3n) // => 3n\n * clamp(0n) // => 1n\n * clamp(6n) // => 5n\n * ```\n *\n * @see {@link between} for checking whether a `bigint` is already inside a range\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const clamp = /*#__PURE__*/order.clamp(Order);\n/**\n * Returns the minimum between two `bigint`s.\n *\n * **When to use**\n *\n * Use to select the smaller of two `bigint` values.\n *\n * **Example** (Finding the minimum bigint)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.min(2n, 3n) // => 2n\n * ```\n *\n * @see {@link max} for selecting the larger value\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const min = /*#__PURE__*/order.min(Order);\n/**\n * Returns the maximum between two `bigint`s.\n *\n * **When to use**\n *\n * Use to select the larger of two `bigint` values.\n *\n * **Example** (Finding the maximum bigint)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.max(2n, 3n) // => 3n\n * ```\n *\n * @see {@link min} for selecting the smaller value\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const max = /*#__PURE__*/order.max(Order);\n/**\n * Determines the sign of a given `bigint`.\n *\n * **When to use**\n *\n * Use to classify a `bigint` as negative, zero, or positive.\n *\n * **Example** (Determining bigint signs)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.sign(-5n) // => -1\n * BigInt.sign(0n) // => 0\n * BigInt.sign(5n) // => 1\n * ```\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const sign = n => order.BigInt(n, bigint0);\n/**\n * Determines the absolute value of a given `bigint`.\n *\n * **When to use**\n *\n * Use to remove the sign from a `bigint` while preserving its magnitude.\n *\n * **Example** (Calculating absolute values)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.abs(-5n) // => 5n\n * BigInt.abs(0n) // => 0n\n * BigInt.abs(5n) // => 5n\n * ```\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const abs = n => n < bigint0 ? -n : n;\n/**\n * Determines the greatest common divisor of two `bigint`s.\n *\n * **When to use**\n *\n * Use to compute the greatest common divisor of two integer values.\n *\n * **Example** (Calculating greatest common divisors)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.gcd(2n, 3n) // => 1n\n * BigInt.gcd(2n, 4n) // => 2n\n * BigInt.gcd(16n, 24n) // => 8n\n * ```\n *\n * @see {@link lcm} for computing the least common multiple\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const gcd = /*#__PURE__*/dual(2, (self, that) => {\n while (that !== bigint0) {\n const t = that;\n that = self % that;\n self = t;\n }\n return abs(self);\n});\n/**\n * Determines the least common multiple of two `bigint`s.\n *\n * **When to use**\n *\n * Use to compute the least common multiple of two integer values.\n *\n * **Example** (Calculating least common multiples)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.lcm(2n, 3n) // => 6n\n * BigInt.lcm(2n, 4n) // => 4n\n * BigInt.lcm(16n, 24n) // => 48n\n * ```\n *\n * @see {@link gcd} for computing the greatest common divisor\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const lcm = /*#__PURE__*/dual(2, (self, that) => self === bigint0 || that === bigint0 ? bigint0 : abs(self * that / gcd(self, that)));\n/**\n * Returns the integer square root of a non-negative `bigint`.\n *\n * **When to use**\n *\n * Use when you need to compute an integer square root for a `bigint` that has\n * already been validated as non-negative, and you want negative input to throw\n * instead of returning `Option.none`.\n *\n * **Details**\n *\n * For non-perfect squares, returns the largest `bigint` whose square is less\n * than or equal to the input.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` if the input is negative.\n *\n * **Example** (Calculating square roots unsafely)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.sqrtUnsafe(4n) // => 2n\n * BigInt.sqrtUnsafe(9n) // => 3n\n * BigInt.sqrtUnsafe(16n) // => 4n\n * ```\n *\n * @see {@link sqrt} for returning `Option.none` when the input is negative\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const sqrtUnsafe = n => {\n if (n < bigint0) {\n throw new RangeError(\"Cannot take the square root of a negative number\");\n }\n if (n < bigint2) {\n return n;\n }\n let x = n / bigint2;\n while (x * x > n) {\n x = (n / x + x) / bigint2;\n }\n return x;\n};\n/**\n * Computes the integer square root of a `bigint` safely.\n *\n * **When to use**\n *\n * Use to compute an integer square root while representing negative input as\n * `Option.none`.\n *\n * **Details**\n *\n * For non-perfect squares, returns the largest `bigint` whose square is less\n * than or equal to the input. Returns `Option.none()` when the input is\n * negative.\n *\n * **Example** (Calculating square roots safely)\n *\n * ```ts import.meta.vitest\n * import { BigInt, Option } from \"effect\"\n *\n * BigInt.sqrt(4n) // => Option.some(2n)\n * BigInt.sqrt(9n) // => Option.some(3n)\n * BigInt.sqrt(16n) // => Option.some(4n)\n * BigInt.sqrt(-1n) // => Option.none()\n * ```\n *\n * @see {@link sqrtUnsafe} for square root computation that throws on negative input\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const sqrt = n => isGreaterThanOrEqualTo(n, bigint0) ? Option.some(sqrtUnsafe(n)) : Option.none();\n/**\n * Takes an `Iterable` of `bigint`s and returns their sum as a single `bigint`. Returns `0n` for an empty iterable.\n *\n * **When to use**\n *\n * Use when you want an immediate aggregate from an iterable instead of a\n * folding reducer owned by another API.\n *\n * **Example** (Summing iterable bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.sumAll([2n, 3n, 4n]) // => 9n\n * ```\n *\n * @see {@link sum} for adding two `bigint` values\n * @see {@link ReducerSum} for summing through APIs that consume a `Reducer`\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const sumAll = collection => {\n let out = bigint0;\n for (const n of collection) {\n out += n;\n }\n return out;\n};\n/**\n * Takes an `Iterable` of `bigint`s and returns their product as a single `bigint`. Returns `1n` for an empty iterable.\n *\n * **When to use**\n *\n * Use to multiply all `bigint` values in an iterable.\n *\n * **Example** (Multiplying iterable bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.multiplyAll([2n, 3n, 4n]) // => 24n\n * ```\n *\n * @see {@link multiply} for multiplying two `bigint` values\n * @see {@link ReducerMultiply} for multiplying through APIs that consume a `Reducer`\n *\n * @stability stable\n * @category math\n * @since 2.0.0\n */\nexport const multiplyAll = collection => {\n let out = bigint1;\n for (const n of collection) {\n if (n === bigint0) {\n return bigint0;\n }\n out *= n;\n }\n return out;\n};\n/**\n * Converts a `bigint` to a `number` safely.\n *\n * **When to use**\n *\n * Use to convert a `bigint` to a JavaScript number only when it is a safe\n * integer.\n *\n * **Details**\n *\n * If the `bigint` is outside the safe integer range for JavaScript (`Number.MAX_SAFE_INTEGER`\n * and `Number.MIN_SAFE_INTEGER`), it returns `Option.none()`.\n *\n * **Example** (Converting bigints to numbers)\n *\n * ```ts import.meta.vitest\n * import { BigInt as BI, Option } from \"effect\"\n *\n * BI.toNumber(42n) // => Option.some(42)\n * BI.toNumber(9007199254740992n) // => Option.none()\n * BI.toNumber(-9007199254740992n) // => Option.none()\n * ```\n *\n * @see {@link fromNumber} for converting a safe integer number to `bigint`\n *\n * @stability stable\n * @category converting\n * @since 2.0.0\n */\nexport const toNumber = b => {\n if (b > BigInt(Number.MAX_SAFE_INTEGER) || b < BigInt(Number.MIN_SAFE_INTEGER)) {\n return Option.none();\n }\n return Option.some(Number(b));\n};\n/**\n * Parses a string into a `bigint` safely.\n *\n * **When to use**\n *\n * Use to parse a string as a `bigint` without throwing on invalid input.\n *\n * **Details**\n *\n * If the string is empty or contains characters that cannot be converted into a\n * `bigint`, it returns `Option.none()`.\n *\n * **Example** (Parsing strings as bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt, Option } from \"effect\"\n *\n * BigInt.fromString(\"42\") // => Option.some(42n)\n * BigInt.fromString(\" \") // => Option.none()\n * BigInt.fromString(\"a\") // => Option.none()\n * ```\n *\n * @see {@link BigInt} for native constructor coercion that throws on invalid input\n *\n * @stability stable\n * @category converting\n * @since 2.4.12\n */\nexport const fromString = s => {\n try {\n return s.trim() === \"\" ? Option.none() : Option.some(BigInt(s));\n } catch {\n return Option.none();\n }\n};\n/**\n * Converts a number to a `bigint`.\n *\n * **When to use**\n *\n * Use to convert a JavaScript number to `bigint` only when it is a safe integer.\n *\n * **Details**\n *\n * If the number is outside the safe integer range for JavaScript\n * (`Number.MAX_SAFE_INTEGER` and `Number.MIN_SAFE_INTEGER`) or if the number is\n * not a valid `bigint`, it returns `Option.none()`.\n *\n * **Example** (Converting numbers to bigints)\n *\n * ```ts import.meta.vitest\n * import { BigInt, Option } from \"effect\"\n *\n * BigInt.fromNumber(42) // => Option.some(42n)\n * BigInt.fromNumber(Number.MAX_SAFE_INTEGER + 1) // => Option.none()\n * BigInt.fromNumber(Number.MIN_SAFE_INTEGER - 1) // => Option.none()\n * ```\n *\n * @see {@link toNumber} for converting `bigint` values back to safe integer numbers\n * @see {@link BigInt} for native constructor coercion\n *\n * @stability stable\n * @category converting\n * @since 2.4.12\n */\nexport function fromNumber(n) {\n if (n > Number.MAX_SAFE_INTEGER || n < Number.MIN_SAFE_INTEGER) {\n return Option.none();\n }\n try {\n return Option.some(BigInt(n));\n } catch {\n return Option.none();\n }\n}\n/**\n * Returns the JavaScript remainder of dividing one `bigint` by another.\n *\n * **When to use**\n *\n * Use when you want native remainder semantics, including signed remainders and\n * a thrown division-by-zero error.\n *\n * **Gotchas**\n *\n * Throws a `RangeError` when the divisor is `0n`.\n *\n * **Example** (Calculating remainders)\n *\n * ```ts import.meta.vitest\n * import { BigInt } from \"effect\"\n *\n * BigInt.remainder(10n, 3n) // => 1n\n * BigInt.remainder(15n, 4n) // => 3n\n * ```\n *\n * @see {@link divide} for quotient calculation with division-by-zero represented as `Option.none`\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const remainder = /*#__PURE__*/dual(2, (self, divisor) => self % divisor);\n/**\n * Reducer for combining `bigint`s using addition.\n *\n * **When to use**\n *\n * Use to sum many `bigint` values through APIs that consume a `Reducer`.\n *\n * **Details**\n *\n * The initial value is `0n`, so `combineAll([])` returns `0n`.\n *\n * @see {@link sumAll} for summing an iterable directly\n * @see {@link ReducerMultiply} for multiplying `bigint` values\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const ReducerSum = /*#__PURE__*/Reducer.make((a, b) => a + b, bigint0);\n/**\n * Reducer for combining `bigint`s using multiplication.\n *\n * **When to use**\n *\n * Use to multiply many `bigint` values through APIs that consume a `Reducer`.\n *\n * **Details**\n *\n * The initial value is `1n`, so `combineAll([])` returns `1n`.\n *\n * @see {@link multiplyAll} for multiplying an iterable directly\n * @see {@link ReducerSum} for summing `bigint` values\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const ReducerMultiply = /*#__PURE__*/Reducer.make((a, b) => a * b, bigint1, collection => {\n let acc = bigint1;\n for (const n of collection) {\n if (n === bigint0) return bigint0;\n acc *= n;\n }\n return acc;\n});\n/**\n * Combiner that returns the maximum `bigint`.\n *\n * **When to use**\n *\n * Use to keep the largest `bigint` when an API consumes a `Combiner`.\n *\n * @see {@link CombinerMin} for keeping the smallest `bigint`\n * @see {@link max} for comparing two `bigint` values directly\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMax = /*#__PURE__*/Combiner.max(Order);\n/**\n * Combiner that returns the minimum `bigint`.\n *\n * **When to use**\n *\n * Use to keep the smallest `bigint` through APIs that consume a `Combiner`.\n *\n * @see {@link CombinerMax} for keeping the largest `bigint`\n * @see {@link min} for comparing two `bigint` values directly\n *\n * @stability stable\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMin = /*#__PURE__*/Combiner.min(Order);\n//# sourceMappingURL=BigInt.js.map",
|
|
10
|
+
"/**\n * Represents exact, non-negative, integral byte counts.\n *\n * Decimal units use powers of 1,000 and binary units use powers of 1,024.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as BI from \"./BigInt.js\";\nimport { dual } from \"./Function.js\";\nimport * as Option from \"./Option.js\";\nconst TypeId = \"~effect/ByteSize\";\nconst bigint0 = /*#__PURE__*/BigInt(0);\nconst bigint1 = /*#__PURE__*/BigInt(1);\nconst decimalBase = /*#__PURE__*/BigInt(1000);\nconst binaryBase = /*#__PURE__*/BigInt(1024);\nconst decimalUnits = [{\n symbol: \"B\",\n factor: bigint1,\n names: [\"B\", \"byte\", \"bytes\"]\n}, {\n symbol: \"kB\",\n factor: decimalBase,\n names: [\"kB\", \"kilobyte\", \"kilobytes\"]\n}, {\n symbol: \"MB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(2),\n names: [\"MB\", \"megabyte\", \"megabytes\"]\n}, {\n symbol: \"GB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(3),\n names: [\"GB\", \"gigabyte\", \"gigabytes\"]\n}, {\n symbol: \"TB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(4),\n names: [\"TB\", \"terabyte\", \"terabytes\"]\n}, {\n symbol: \"PB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(5),\n names: [\"PB\", \"petabyte\", \"petabytes\"]\n}, {\n symbol: \"EB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(6),\n names: [\"EB\", \"exabyte\", \"exabytes\"]\n}, {\n symbol: \"ZB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(7),\n names: [\"ZB\", \"zettabyte\", \"zettabytes\"]\n}, {\n symbol: \"YB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(8),\n names: [\"YB\", \"yottabyte\", \"yottabytes\"]\n}, {\n symbol: \"RB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(9),\n names: [\"RB\", \"ronnabyte\", \"ronnabytes\"]\n}, {\n symbol: \"QB\",\n factor: decimalBase ** /*#__PURE__*/BigInt(10),\n names: [\"QB\", \"quettabyte\", \"quettabytes\"]\n}];\nconst binaryUnits = [decimalUnits[0], {\n symbol: \"KiB\",\n factor: binaryBase,\n names: [\"KiB\", \"kibibyte\", \"kibibytes\"]\n}, {\n symbol: \"MiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(2),\n names: [\"MiB\", \"mebibyte\", \"mebibytes\"]\n}, {\n symbol: \"GiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(3),\n names: [\"GiB\", \"gibibyte\", \"gibibytes\"]\n}, {\n symbol: \"TiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(4),\n names: [\"TiB\", \"tebibyte\", \"tebibytes\"]\n}, {\n symbol: \"PiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(5),\n names: [\"PiB\", \"pebibyte\", \"pebibytes\"]\n}, {\n symbol: \"EiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(6),\n names: [\"EiB\", \"exbibyte\", \"exbibytes\"]\n}, {\n symbol: \"ZiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(7),\n names: [\"ZiB\", \"zebibyte\", \"zebibytes\"]\n}, {\n symbol: \"YiB\",\n factor: binaryBase ** /*#__PURE__*/BigInt(8),\n names: [\"YiB\", \"yobibyte\", \"yobibytes\"]\n}];\nconst allUnits = [...decimalUnits, ... /*#__PURE__*/binaryUnits.slice(1)];\nconst unitsByName = /*#__PURE__*/new Map(/*#__PURE__*/allUnits.flatMap(unit => unit.names.map(name => [name, unit])));\nconst unitsBySymbol = /*#__PURE__*/new Map(/*#__PURE__*/allUnits.map(unit => [unit.symbol, unit]));\nconst make = value => value;\n/**\n * The byte size containing zero bytes.\n *\n * @stability unstable\n * @category constants\n * @since 4.0.0\n */\nexport const zero = /*#__PURE__*/make(bigint0);\nconst invalid = message => {\n throw new Error(`Invalid ByteSize: ${message}`);\n};\nconst fromNumber = input => {\n if (!Number.isSafeInteger(input) || input < 0) {\n return invalid(`expected a non-negative safe integer, received ${input}`);\n }\n return make(BigInt(input));\n};\nconst maxSafeInteger = /*#__PURE__*/BigInt(Number.MAX_SAFE_INTEGER);\n// Exactly multiplies a decimal such as \"2.01\" or \"4e-15\" by `factor`, or `undefined` for a fractional byte result\nconst scaleDecimal = (quantity, factor) => {\n const match = /^(\\d+)(?:\\.(\\d+))?(?:e([+-]\\d+))?$/.exec(quantity);\n if (match === null) return undefined;\n const fraction = match[2] ?? \"\";\n const numerator = BigInt(match[1] + fraction) * factor;\n const shift = Number(match[3] ?? 0) - fraction.length;\n if (shift >= 0) return numerator * BigInt(10) ** BigInt(shift);\n const scale = BigInt(10) ** BigInt(-shift);\n return numerator % scale === bigint0 ? numerator / scale : undefined;\n};\nconst fromQuantity = (quantity, unit) => {\n if (typeof quantity === \"bigint\") {\n if (quantity < bigint0) return invalid(`expected a non-negative quantity, received ${quantity}`);\n return make(quantity * unit.factor);\n }\n if (binaryUnits.includes(unit)) {\n // Binary factors are powers of 2, so the float product is exact\n const value = quantity * Number(unit.factor);\n if (Number.isSafeInteger(value) && value >= 0) return make(BigInt(value));\n } else {\n // Scale the shortest decimal form to avoid floating-point rounding\n const value = scaleDecimal(String(quantity), unit.factor);\n if (value !== undefined && value <= maxSafeInteger) return make(value);\n }\n return invalid(`expected an exact non-negative safe-integer byte result, received ${quantity} ${unit.symbol}`);\n};\n/**\n * Parses a byte-size string and throws for invalid syntax, unsupported units,\n * or quantities that do not represent non-negative integral bytes.\n *\n * **Details**\n *\n * Accepts decimal fractions, canonical SI and IEC symbols, lowercase unit\n * names, and whitespace around the quantity and unit. Parsing uses exact\n * bigint arithmetic, including above the safe integer range.\n *\n * @see {@link fromString} for non-throwing validation\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromStringUnsafe = input => {\n const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*([A-Za-z]+)\\s*$/.exec(input);\n if (match === null) return invalid(`unsupported syntax ${JSON.stringify(input)}`);\n const unit = unitsByName.get(match[2]);\n if (unit === undefined) return invalid(`unsupported unit ${JSON.stringify(match[2])}`);\n const value = scaleDecimal(match[1], unit.factor);\n if (value === undefined) return invalid(`${JSON.stringify(input)} does not represent an integral number of bytes`);\n return make(value);\n};\n/**\n * Parses a byte-size string, returning `None` for invalid syntax, unsupported\n * units, or quantities that do not represent non-negative integral bytes.\n *\n * **Details**\n *\n * Accepts external strings and fractional quantities using the same syntax\n * as `fromStringUnsafe`.\n *\n * @see {@link fromStringUnsafe} for throwing validation\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromString = /*#__PURE__*/Option.liftThrowable(fromStringUnsafe);\n/**\n * Decodes a trusted input into a byte size and throws for invalid input.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromInputUnsafe = input => {\n switch (typeof input) {\n case \"bigint\":\n if (input < bigint0) return invalid(`expected a non-negative bigint, received ${input}`);\n return make(input);\n case \"number\":\n return fromNumber(input);\n case \"string\":\n return fromStringUnsafe(input);\n }\n return invalid(`unsupported input ${input}`);\n};\n/**\n * Decodes an input into a byte size, returning `None` for invalid input.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromInput = /*#__PURE__*/Option.liftThrowable(fromInputUnsafe);\n/**\n * Creates a byte size from a non-negative byte count.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const bytes = value => typeof value === \"bigint\" ? fromInputUnsafe(value) : fromNumber(value);\nconst unitConstructor = symbol => value => fromQuantity(value, unitsBySymbol.get(symbol));\n/**\n * Creates a decimal kilobyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const kilobytes = /*#__PURE__*/unitConstructor(\"kB\");\n/**\n * Creates a decimal megabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const megabytes = /*#__PURE__*/unitConstructor(\"MB\");\n/**\n * Creates a decimal gigabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const gigabytes = /*#__PURE__*/unitConstructor(\"GB\");\n/**\n * Creates a decimal terabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const terabytes = /*#__PURE__*/unitConstructor(\"TB\");\n/**\n * Creates a decimal petabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const petabytes = /*#__PURE__*/unitConstructor(\"PB\");\n/**\n * Creates a decimal exabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const exabytes = /*#__PURE__*/unitConstructor(\"EB\");\n/**\n * Creates a decimal zettabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const zettabytes = /*#__PURE__*/unitConstructor(\"ZB\");\n/**\n * Creates a decimal yottabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const yottabytes = /*#__PURE__*/unitConstructor(\"YB\");\n/**\n * Creates a decimal ronnabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const ronnabytes = /*#__PURE__*/unitConstructor(\"RB\");\n/**\n * Creates a decimal quettabyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const quettabytes = /*#__PURE__*/unitConstructor(\"QB\");\n/**\n * Creates a binary kibibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const kibibytes = /*#__PURE__*/unitConstructor(\"KiB\");\n/**\n * Creates a binary mebibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const mebibytes = /*#__PURE__*/unitConstructor(\"MiB\");\n/**\n * Creates a binary gibibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const gibibytes = /*#__PURE__*/unitConstructor(\"GiB\");\n/**\n * Creates a binary tebibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const tebibytes = /*#__PURE__*/unitConstructor(\"TiB\");\n/**\n * Creates a binary pebibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const pebibytes = /*#__PURE__*/unitConstructor(\"PiB\");\n/**\n * Creates a binary exbibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const exbibytes = /*#__PURE__*/unitConstructor(\"EiB\");\n/**\n * Creates a binary zebibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const zebibytes = /*#__PURE__*/unitConstructor(\"ZiB\");\n/**\n * Creates a binary yobibyte value.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const yobibytes = /*#__PURE__*/unitConstructor(\"YiB\");\n/**\n * Checks whether a value is a byte size.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isByteSize = input => typeof input === \"bigint\" && input >= bigint0;\n/**\n * Checks whether a byte size is zero.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const isZero = self => self === bigint0;\n/**\n * Returns the exact byte count as a bigint.\n *\n * @stability unstable\n * @category getters\n * @since 4.0.0\n */\nexport const toBigInt = self => self;\n/**\n * Converts a byte size to a safe integer, returning `None` when it is too large.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toNumber = BI.toNumber;\n/**\n * Converts a byte size to a safe integer and throws when it is too large.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const toNumberUnsafe = self => Option.getOrThrowWith(toNumber(self), () => new Error(`ByteSize exceeds Number.MAX_SAFE_INTEGER: ${self}`));\n/**\n * Converts a byte size to an approximate number of the specified unit.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toUnit = /*#__PURE__*/dual(2, (self, unit) => Number(self) / Number(unitsBySymbol.get(unit).factor));\n/**\n * Provides an order for byte sizes.\n *\n * @stability unstable\n * @category instances\n * @since 4.0.0\n */\nexport const Order = BI.Order;\n/**\n * Provides an equivalence for byte sizes.\n *\n * @stability unstable\n * @category instances\n * @since 4.0.0\n */\nexport const Equivalence = BI.Equivalence;\n/**\n * Returns whether a byte size is in an inclusive range.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const between = BI.between;\n/**\n * Returns the smaller byte size.\n *\n * @stability unstable\n * @category ordering\n * @since 4.0.0\n */\nexport const min = BI.min;\n/**\n * Returns the larger byte size.\n *\n * @stability unstable\n * @category ordering\n * @since 4.0.0\n */\nexport const max = BI.max;\n/**\n * Constrains a byte size to an inclusive range.\n *\n * @stability unstable\n * @category ordering\n * @since 4.0.0\n */\nexport const clamp = BI.clamp;\n/**\n * Checks whether the first byte size is less than the second.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThan = BI.isLessThan;\n/**\n * Checks whether the first byte size is at most the second.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const isLessThanOrEqualTo = BI.isLessThanOrEqualTo;\n/**\n * Checks whether the first byte size is greater than the second.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThan = BI.isGreaterThan;\n/**\n * Checks whether the first byte size is at least the second.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const isGreaterThanOrEqualTo = BI.isGreaterThanOrEqualTo;\n/**\n * Checks whether two byte sizes contain the same count.\n *\n * @stability unstable\n * @category predicates\n * @since 4.0.0\n */\nexport const equals = /*#__PURE__*/dual(2, Equivalence);\n/**\n * Adds two byte sizes exactly.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const sum = BI.sum;\n/**\n * Subtracts byte sizes, returning `None` on underflow.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const subtract = /*#__PURE__*/dual(2, (self, that) => self < that ? Option.none() : Option.some(make(self - that)));\n/**\n * Subtracts byte sizes and throws on underflow.\n *\n * @stability unstable\n * @category unsafe\n * @since 4.0.0\n */\nexport const subtractUnsafe = /*#__PURE__*/dual(2, (self, that) => {\n if (self < that) throw new Error(`ByteSize subtraction underflow: ${self} - ${that}`);\n return make(self - that);\n});\nconst scalar = (input, positive) => {\n if (typeof input === \"bigint\") return input >= (positive ? bigint1 : bigint0) ? input : undefined;\n return Number.isSafeInteger(input) && input >= (positive ? 1 : 0) ? BigInt(input) : undefined;\n};\n/**\n * Multiplies a byte size by a non-negative integer scalar.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const times = /*#__PURE__*/dual(2, (self, multiplier) => {\n const value = scalar(multiplier, false);\n return value === undefined ? Option.none() : Option.some(make(self * value));\n});\n/**\n * Divides a byte size by a positive integer, discarding any remainder.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const divide = /*#__PURE__*/dual(2, (self, divisor) => {\n const value = scalar(divisor, true);\n return value === undefined ? Option.none() : Option.some(make(self / value));\n});\nconst validatePrecision = precision => {\n if (!Number.isSafeInteger(precision) || precision < 0 || precision > 20) {\n throw new Error(`ByteSize format precision must be an integer from 0 to 20, received ${precision}`);\n }\n return precision;\n};\nconst formatWithUnit = (value, unit, precision, trailingZeros) => {\n const scale = BigInt(10) ** BigInt(precision);\n const rounded = (value * scale * BigInt(2) + unit.factor) / (unit.factor * BigInt(2));\n const whole = rounded / scale;\n if (precision === 0) return `${whole} ${unit.symbol}`;\n let fraction = `${rounded % scale}`.padStart(precision, \"0\");\n if (!trailingZeros) fraction = fraction.replace(/0+$/, \"\");\n return `${whole}${fraction.length === 0 ? \"\" : `.${fraction}`} ${unit.symbol}`;\n};\n/**\n * Formats a byte size with canonical decimal or binary unit symbols.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const format = (self, options = {}) => {\n const precision = validatePrecision(options.precision ?? 2);\n const trailingZeros = options.trailingZeros ?? false;\n if (options.unit !== undefined) {\n return formatWithUnit(self, unitsBySymbol.get(options.unit), precision, trailingZeros);\n }\n const units = options.system === \"decimal\" ? decimalUnits : binaryUnits;\n if (self === bigint0) return \"0 B\";\n let index = units.length - 1;\n while (index > 0 && self < units[index].factor) index--;\n if (index < units.length - 1) {\n const scale = BigInt(10) ** BigInt(precision);\n const rounded = (self * scale * BigInt(2) + units[index].factor) / (units[index].factor * BigInt(2));\n const base = options.system === \"decimal\" ? decimalBase : binaryBase;\n if (rounded >= base * scale) index++;\n }\n return formatWithUnit(self, units[index], precision, trailingZeros);\n};\n/**\n * Reducer that sums byte sizes from zero.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const ReducerSum = BI.ReducerSum;\n/**\n * Combiner that keeps the largest byte size.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMax = BI.CombinerMax;\n/**\n * Combiner that keeps the smallest byte size.\n *\n * @stability unstable\n * @category math\n * @since 4.0.0\n */\nexport const CombinerMin = BI.CombinerMin;\n//# sourceMappingURL=ByteSize.js.map",
|
|
11
|
+
"/**\n * The `CryptoError` returned by the `effect/crypto` modules, and the reasons it\n * carries.\n *\n * Every failure is one `CryptoError` whose `module` and `method` name the\n * operation, such as `\"Aead\"` and `\"decrypt\"`, and whose `reason` says what\n * went wrong: `InvalidArgument`, `InvalidKey`, `DecryptionFailed`,\n * `Unsupported`, or `NotExtractable`.\n *\n * **Gotchas**\n *\n * The error is not serializable, so it cannot be a typed failure in an Rpc or\n * HttpApi schema. Map it before it reaches a client, for example\n * `DecryptionFailed` to a 401. Sending crypto failure detail to clients is how\n * oracles leak.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Data from \"../Data.js\";\nimport * as Predicate from \"../Predicate.js\";\nconst TypeId = \"~effect/crypto/CryptoError\";\nconst ReasonTypeId = \"~effect/crypto/CryptoError/Reason\";\n/**\n * Reason for an argument that the operation rejects before using the key or\n * data, such as a wrong nonce length, an out-of-range iteration count, or\n * `info` passed to a key derivation other than HKDF.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class InvalidArgument extends /*#__PURE__*/Data.TaggedError(\"InvalidArgument\") {\n /**\n * Marks this value as a `CryptoError` reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n get message() {\n return this.description;\n }\n}\n/**\n * Reason for key material that is rejected, such as a wrong raw key length,\n * malformed DER, PEM, or JWK data, a `CryptoKey` that does not match the typed\n * key, or a peer public key that produces an all-zero shared secret.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class InvalidKey extends /*#__PURE__*/Data.TaggedError(\"InvalidKey\") {\n /**\n * Marks this value as a `CryptoError` reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n get message() {\n return this.description;\n }\n}\n/**\n * Reason for a decryption or unwrap that failed its integrity check, or a CBC\n * ciphertext with bad padding or length.\n *\n * **Details**\n *\n * The reason is identical for every cause and carries no `cause` or runtime\n * message, so callers cannot tell a tampered tag from bad padding. Keeping\n * either would create a padding oracle.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class DecryptionFailed extends /*#__PURE__*/Data.TaggedError(\"DecryptionFailed\") {\n /**\n * Marks this value as a `CryptoError` reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n get message() {\n return \"Could not decrypt the data\";\n }\n}\n/**\n * Reason for an algorithm or key that a layer does not provide, such as\n * Argon2id under `Kdf.layerWebCrypto`, or a `CryptoKey`-backed key passed to a\n * layer that cannot use it.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class Unsupported extends /*#__PURE__*/Data.TaggedError(\"Unsupported\") {\n /**\n * Marks this value as a `CryptoError` reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n get message() {\n return this.description;\n }\n}\n/**\n * Reason for exporting or wrapping a `CryptoKey` that was created as\n * non-extractable.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class NotExtractable extends /*#__PURE__*/Data.TaggedError(\"NotExtractable\") {\n /**\n * Marks this value as a `CryptoError` reason for runtime guards.\n *\n * @since 4.0.0\n */\n [ReasonTypeId] = ReasonTypeId;\n get message() {\n return this.description;\n }\n}\n/**\n * Error returned by the `effect/crypto` modules.\n *\n * **When to use**\n *\n * Use to handle failures from any `effect/crypto` operation, matching on\n * `reason` to separate caller mistakes from failed decryption.\n *\n * **Details**\n *\n * `module` and `method` name the operation, such as `\"Aead\"` and `\"decrypt\"`.\n * The message reads `\"Aead.decrypt: <reason message>\"`. The error's `cause`\n * is the reason's `cause`, when it has one.\n *\n * **Example** (Recovering from failed decryption)\n *\n * ```ts import.meta.vitest\n * import { Effect } from \"effect\"\n * import { CryptoError } from \"effect/crypto\"\n *\n * const decrypt = Effect.fail(\n * new CryptoError.CryptoError({\n * module: \"Aead\",\n * method: \"decrypt\",\n * reason: new CryptoError.DecryptionFailed()\n * })\n * )\n *\n * const program = decrypt.pipe(\n * Effect.catchReason(\"CryptoError\", \"DecryptionFailed\", () => Effect.succeed(\"rejected\"))\n * )\n *\n * await Effect.runPromise(program) // => \"rejected\"\n * ```\n *\n * @see {@link isCryptoError} for narrowing unknown values\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class CryptoError extends /*#__PURE__*/Data.TaggedError(\"CryptoError\") {\n /**\n * Marks this value as a `CryptoError` for runtime guards.\n *\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n /**\n * The reason's cause, when it has one.\n *\n * @since 4.0.0\n */\n cause = \"cause\" in this.reason ? this.reason.cause : undefined;\n get message() {\n return `${this.module}.${this.method}: ${this.reason.message}`;\n }\n}\n/**\n * Checks whether a value is a `CryptoError`.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isCryptoError = u => Predicate.hasProperty(u, TypeId);\n/**\n * Checks whether a value is one of the reasons carried by `CryptoError`.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isCryptoErrorReason = u => Predicate.hasProperty(u, ReasonTypeId);\n//# sourceMappingURL=CryptoError.js.map",
|
|
12
|
+
"/**\n * ChaCha20-Poly1305 (RFC 8439) and XChaCha20-Poly1305\n * (draft-irtf-cfrg-xchacha-03), vendored from `@noble/ciphers`.\n *\n * Upstream: https://github.com/paulmillr/noble-ciphers\n * Version: 2.4.0, commit d9e8a6a599e7ed729d9be03854c46a3c73bd9a79\n * Files: `src/chacha.ts` (`chachaCore`, `hchacha`, `chacha20`, `xchacha20`,\n * `_poly1305_aead`), `src/_arx.ts` (`createCipher`), `src/_poly1305.ts`\n * (`Poly1305`), and the helpers they use from `src/utils.ts`. `@noble/ciphers`\n * 1.0.0 was audited by Cure53 in 2024.\n *\n * Changes from upstream: merged into one file, removed the `TArg`/`TRet` type\n * helpers, `@example` blocks, the reduced-round and original ChaCha variants,\n * the PRGs, and the `wrapCipher` argument wrapper, whose checks the `Aead`\n * layers run before calling this code. `Poly1305` is constructed directly\n * instead of through `wrapMacConstructor`, and `decrypt` returns `undefined`\n * on a tag mismatch instead of throwing, so any exception is a bug. The\n * cipher core, Poly1305 arithmetic, and AEAD construction are unchanged.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2022 Paul Miller (https://paulmillr.com)\n * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * @internal\n */\nfunction isBytes(a) {\n // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy /\n // cross-realm cases. The fallback still requires a real ArrayBuffer view\n // so plain JSON-deserialized `{ constructor: ... }`\n // spoofing is rejected, and `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.\n return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === \"Uint8Array\" && \"BYTES_PER_ELEMENT\" in a && a.BYTES_PER_ELEMENT === 1;\n}\nconst atitle = title => title ? `\"${title}\" ` : \"\";\nfunction abool(value, title = \"\") {\n if (typeof value !== \"boolean\") {\n throw new TypeError(atitle(title) + \"expected boolean, got type=\" + typeof value);\n }\n return value;\n}\nfunction anumber(n, title = \"\") {\n if (typeof n !== \"number\") {\n throw new TypeError(atitle(title) + \"expected number, got \" + typeof n);\n }\n if (!Number.isSafeInteger(n) || n < 0) {\n throw new RangeError(atitle(title) + \"expected integer >= 0, got \" + n);\n }\n return n;\n}\nfunction abytes(value, length, title = \"\") {\n // Success path first: this runs at the start of every update() / digestInto(), and the\n // common `abytes(data)` form must not pay for length handling it does not use.\n if (isBytes(value) && (length === undefined || value.length === length)) {\n return value;\n }\n // Error path: recompute freely to build the exact message.\n if (length !== undefined) anumber(length, \"length\");\n const bytes = isBytes(value);\n const ofLen = length !== undefined ? ` of length ${length}` : \"\";\n const got = bytes ? `length=${value.length}` : `type=${typeof value}`;\n const message = atitle(title) + \"expected Uint8Array\" + ofLen + \", got \" + got;\n if (!bytes) throw new TypeError(message);\n throw new RangeError(message);\n}\nconst aobject = (value, label) => {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(label === \"object\" ? \"expected valid options object\" : `\"${label}\" expected object, got type=${typeof value}`);\n }\n};\nfunction checkOpts(defaults, opts) {\n aobject(defaults, \"defaults\");\n aobject(opts, \"opts\");\n // Mutates defaults by design. __proto__ follows Object.assign semantics here and can only\n // affect this local option object; callers already control this low-level options surface.\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nfunction aexists(instance, checkFinished = true) {\n // Runs on every update()/digestInto(); the flags are library-owned booleans, so only their\n // truthiness is checked - re-validating their type per call was pure hot-path overhead.\n if (instance.destroyed) throw new Error(\"hash was destroyed\");\n if (checkFinished && instance.finished) throw new Error(\"digest() was already called\");\n}\nfunction aoutput(out, instance) {\n abytes(out, undefined, \"output\");\n // `outputLen` is a library-owned readonly number; the negated comparison keeps failing fast\n // when it is missing/NaN (comparisons with undefined/NaN are false) without an anumber() call.\n const min = instance.outputLen;\n if (!(out.length >= min)) {\n throw new RangeError(\"\\\"output\\\" expected length >= \" + min);\n }\n}\nfunction u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\nfunction clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\nfunction createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\nconst isLE = /* @__PURE__ */(() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\nfunction byteSwap(word) {\n return word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff;\n}\nfunction byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\nconst swap32IfBE = isLE ? u => u : byteSwap32;\nfunction overlapBytes(a, b) {\n // Zero-length views cannot overwrite anything, even if their offset sits inside another range.\n if (!a.byteLength || !b.byteLength) return false;\n return a.buffer === b.buffer &&\n // best we can do, may fail with an obscure Proxy\n a.byteOffset < b.byteOffset + b.byteLength &&\n // a starts before b end\n b.byteOffset < a.byteOffset + a.byteLength // b starts before a end\n;\n}\nfunction complexOverlapBytes(input, output) {\n // This is very cursed. It works somehow, but I'm completely unsure,\n // reasoning about overlapping aligned windows is very hard.\n if (overlapBytes(input, output) && input.byteOffset < output.byteOffset) {\n throw new Error(\"complex overlap of input and output is not supported\");\n }\n}\nfunction equalBytes(a, b) {\n a = abytes(a);\n b = abytes(b);\n if (a.length !== b.length) return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];\n return diff === 0;\n}\nfunction getOutput(expectedLength, out, onlyAligned = true) {\n if (out === undefined) return new Uint8Array(expectedLength);\n // Keep Buffer/cross-realm Uint8Array support here instead of trusting a shape-compatible object.\n abytes(out, expectedLength, \"output\");\n if (onlyAligned && !isAligned32(out)) throw new Error(\"invalid output, must be aligned\");\n return out;\n}\nfunction u64Lengths(dataLength, aadLength, isLE) {\n // Reject coercible non-number lengths like '10' and true before BigInt(...) accepts them.\n anumber(dataLength);\n anumber(aadLength);\n abool(isLE);\n const num = new Uint8Array(16);\n const view = createView(num);\n view.setBigUint64(0, BigInt(aadLength), isLE);\n view.setBigUint64(8, BigInt(dataLength), isLE);\n return num;\n}\nfunction isAligned32(bytes) {\n return bytes.byteOffset % 4 === 0;\n}\nfunction copyBytes(bytes) {\n // `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict\n // because callers use it at byte-validation boundaries before mutating the detached copy.\n return Uint8Array.from(abytes(bytes));\n}\n// _arx.ts\n// Replaces `TextEncoder` for ASCII literals, which is enough for sigma constants.\n// Non-ASCII input would not match UTF-8 `TextEncoder` output.\nconst encodeStr = str => Uint8Array.from(str.split(\"\"), c => c.charCodeAt(0));\n// Raw `createCipher(...)` exports consume these native-endian `u32(...)` views directly.\n// RFC 8439 §2.3 / RFC 7539 §2.3 only define the 256-bit-key constants; this 16-byte sigma is\n// kept for legacy allowShortKeys Salsa/ChaCha variants.\nconst sigma16_32 = /* @__PURE__ */(() => swap32IfBE(u32(encodeStr(\"expand 16-byte k\"))))();\n// RFC 8439 §2.3 / RFC 7539 §2.3 define words 0-3 as\n// `0x61707865 0x3320646e 0x79622d32 0x6b206574`, i.e. `expand 32-byte k`.\nconst sigma32_32 = /* @__PURE__ */(() => swap32IfBE(u32(encodeStr(\"expand 32-byte k\"))))();\nfunction rotl(a, b) {\n return a << b | a >>> 32 - b;\n}\n// Salsa and Chacha block length is always 512-bit\nconst BLOCK_LEN = 64;\n// RFC 8439 §2.2 / RFC 7539 §2.2: the ChaCha state has 16 32-bit words.\nconst BLOCK_LEN32 = 16;\n// Counter policy for the shared public `counter` argument:\n// - RFC/IETF ChaCha20 uses a 32-bit counter.\n// - OpenSSL/Node `chacha20` instead treat the full 16-byte IV as a 128-bit\n// counter state and carry into the next word.\n// - Raw `chacha20orig`, `salsa20`, `xsalsa20`, and `xchacha20` use 64-bit counters in libsodium\n// and libtomcrypt, while some libs (for example libtomcrypt's RFC/IETF path) reject the max\n// boundary instead of carrying.\n// - AEAD wrappers diverge too: libsodium `xchacha20poly1305` uses the IETF payload counter from\n// block 1, while `secretstream_xchacha20poly1305` is a different protocol with rekey/reset.\n// Noble intentionally throws instead of silently picking one wrap model for users. In the default\n// path, even a 32-bit boundary would take 2^32 blocks * 64 bytes = 256 GiB, which is practically\n// unreachable for normal JS callers; advanced users who pass `counter` explicitly can implement\n// whatever wider carry / wrap policy they need on top.\nconst MAX_COUNTER = /* @__PURE__ */(() => 2 ** 32 - 1)();\nconst U32_EMPTY = /* @__PURE__ */Uint32Array.of();\nfunction runCipher(core, sigma, key, nonce, data, output, counter, rounds) {\n const len = data.length;\n const block = new Uint8Array(BLOCK_LEN);\n const b32 = u32(block);\n // Make sure that buffers aligned to 4 bytes\n const isAligned = isLE && isAligned32(data) && isAligned32(output);\n const d32 = isAligned ? u32(data) : U32_EMPTY;\n const o32 = isAligned ? u32(output) : U32_EMPTY;\n // RFC 8439 §2.4.1 / RFC 7539 §2.4.1 allow XORing one keystream block at a time and\n // truncating the final partial block instead of materializing the whole keystream.\n if (!isLE) {\n for (let pos = 0; pos < len; counter++) {\n core(sigma, key, nonce, b32, counter, rounds);\n // RFC 8439 §2.4 / RFC 7539 §2.4 serialize keystream words in little-endian order.\n swap32IfBE(b32);\n if (counter >= MAX_COUNTER) throw new Error(\"arx: counter overflow\");\n const take = Math.min(BLOCK_LEN, len - pos);\n for (let j = 0, posj; j < take; j++) {\n posj = pos + j;\n output[posj] = data[posj] ^ block[j];\n }\n pos += take;\n }\n return;\n }\n for (let pos = 0; pos < len; counter++) {\n core(sigma, key, nonce, b32, counter, rounds);\n // See MAX_COUNTER policy note above: never silently wrap the shared public counter.\n if (counter >= MAX_COUNTER) throw new Error(\"arx: counter overflow\");\n const take = Math.min(BLOCK_LEN, len - pos);\n // aligned to 4 bytes\n if (isAligned && take === BLOCK_LEN) {\n const pos32 = pos / 4;\n if (pos % 4 !== 0) throw new Error(\"arx: invalid block position\");\n for (let j = 0, posj; j < BLOCK_LEN32; j++) {\n posj = pos32 + j;\n o32[posj] = d32[posj] ^ b32[j];\n }\n pos += BLOCK_LEN;\n continue;\n }\n for (let j = 0, posj; j < take; j++) {\n posj = pos + j;\n output[posj] = data[posj] ^ block[j];\n }\n pos += take;\n }\n}\nfunction createCipher(core, opts) {\n const {\n allowShortKeys,\n extendNonceFn,\n counterLength,\n counterRight,\n rounds\n } = checkOpts({\n allowShortKeys: false,\n counterLength: 8,\n counterRight: false,\n rounds: 20\n }, opts);\n if (typeof core !== \"function\") throw new Error(\"core must be a function\");\n anumber(counterLength);\n anumber(rounds);\n abool(counterRight);\n abool(allowShortKeys);\n return (key, nonce, data, output, counter = 0) => {\n abytes(key, undefined, \"key\");\n abytes(nonce, undefined, \"nonce\");\n abytes(data, undefined, \"data\");\n const len = data.length;\n // Raw XorStream APIs return ciphertext/plaintext bytes directly, so caller-provided outputs\n // must match the logical result length exactly instead of returning an oversized workspace.\n const hasOutput = output !== undefined;\n output = getOutput(len, output, false);\n if (hasOutput) complexOverlapBytes(data, output);\n anumber(counter);\n // See MAX_COUNTER policy note above: reject advanced explicit-counter requests before any wrap.\n if (counter < 0 || counter >= MAX_COUNTER) throw new Error(\"arx: counter overflow\");\n const toClean = [];\n // Key & sigma\n // key=16 -> sigma16, k=key|key\n // key=32 -> sigma32, k=key\n let l = key.length;\n let k;\n let sigma;\n if (l === 32) {\n // Copy caller keys too: big-endian normalization, extended-nonce subkey derivation, and\n // final clean(...) all mutate or wipe the temporary buffer in place.\n toClean.push(k = copyBytes(key));\n sigma = sigma32_32;\n } else if (l === 16 && allowShortKeys) {\n k = new Uint8Array(32);\n k.set(key);\n k.set(key, 16);\n sigma = sigma16_32;\n toClean.push(k);\n } else {\n abytes(key, 32, \"arx key\");\n throw new Error(\"invalid key size\");\n // throw new Error(`\"arx key\" expected Uint8Array of length 32, got length=${l}`);\n }\n // Nonce\n // salsa20: 8 (8-byte counter)\n // chacha20orig: 8 (8-byte counter)\n // chacha20: 12 (4-byte counter)\n // xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce)\n // xchacha20: 24 (16 -> hchacha, 8 -> old nonce)\n // Copy before taking u32(...) views on misaligned inputs, and on big-endian so later\n // swap32IfBE(...) never mutates caller nonce bytes in place.\n if (!isLE || !isAligned32(nonce)) toClean.push(nonce = copyBytes(nonce));\n let k32 = u32(k);\n // hsalsa & hchacha: handle extended nonce\n if (extendNonceFn) {\n if (nonce.length !== 24) throw new Error(\"arx: extended nonce must be 24 bytes\");\n const n16 = nonce.subarray(0, 16);\n if (isLE) extendNonceFn(sigma, k32, u32(n16), k32);else {\n const sigmaRaw = swap32IfBE(Uint32Array.from(sigma));\n extendNonceFn(sigmaRaw, k32, u32(n16), k32);\n clean(sigmaRaw);\n swap32IfBE(k32);\n }\n nonce = nonce.subarray(16);\n } else if (!isLE) swap32IfBE(k32);\n // Handle nonce counter\n const nonceNcLen = 16 - counterLength;\n if (nonceNcLen !== nonce.length) {\n throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);\n }\n // Normalize 64-bit-nonce layouts to the 12-byte core input: ChaCha/XChaCha prefix 4 zero\n // counter bytes, while Salsa/XSalsa append them after the nonce words.\n if (nonceNcLen !== 12) {\n const nc = new Uint8Array(12);\n nc.set(nonce, counterRight ? 0 : 12 - nonce.length);\n nonce = nc;\n toClean.push(nonce);\n }\n const n32 = swap32IfBE(u32(nonce));\n // Ensure temporary key/nonce copies are wiped even if the remaining\n // runtime guard in runCipher(...) throws on counter overflow.\n try {\n runCipher(core, sigma, k32, n32, data, output, counter, rounds);\n return output;\n } finally {\n clean(...toClean);\n }\n };\n}\n// _poly1305.ts\n// Little-endian 2-byte load used by the Poly1305 limb decomposition.\nfunction u8to16(a, i) {\n return a[i++] & 0xff | (a[i++] & 0xff) << 8;\n}\nclass Poly1305 {\n blockLen = 16;\n outputLen = 16;\n buffer = /*#__PURE__*/new Uint8Array(16);\n r = /*#__PURE__*/new Uint16Array(10); // Allocating 1 array with .subarray() here is slower than 3\n h = /*#__PURE__*/new Uint16Array(10);\n pad = /*#__PURE__*/new Uint16Array(8);\n pos = 0;\n finished = false;\n destroyed = false;\n // Can be speed-up using BigUint64Array, at the cost of complexity\n constructor(key) {\n key = copyBytes(abytes(key, 32, \"key\"));\n const t0 = u8to16(key, 0);\n const t1 = u8to16(key, 2);\n const t2 = u8to16(key, 4);\n const t3 = u8to16(key, 6);\n const t4 = u8to16(key, 8);\n const t5 = u8to16(key, 10);\n const t6 = u8to16(key, 12);\n const t7 = u8to16(key, 14);\n // RFC 8439 §2.5.1 / RFC 7539 §2.5.1 clamp r before multiplication.\n // These masks unpack that clamped value into 13-bit limbs, while pad\n // keeps the raw s half for finalize().\n // {@link https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47 | poly1305-donna reference}\n this.r[0] = t0 & 0x1fff;\n this.r[1] = (t0 >>> 13 | t1 << 3) & 0x1fff;\n this.r[2] = (t1 >>> 10 | t2 << 6) & 0x1f03;\n this.r[3] = (t2 >>> 7 | t3 << 9) & 0x1fff;\n this.r[4] = (t3 >>> 4 | t4 << 12) & 0x00ff;\n this.r[5] = t4 >>> 1 & 0x1ffe;\n this.r[6] = (t4 >>> 14 | t5 << 2) & 0x1fff;\n this.r[7] = (t5 >>> 11 | t6 << 5) & 0x1f81;\n this.r[8] = (t6 >>> 8 | t7 << 8) & 0x1fff;\n this.r[9] = t7 >>> 5 & 0x007f;\n for (let i = 0; i < 8; i++) this.pad[i] = u8to16(key, 16 + 2 * i);\n }\n process(data, offset, isLast = false) {\n // RFC 8439 §2.5 / §2.5.1 and RFC 7539 §2.5 / §2.5.1 add an extra high\n // bit to every full 16-byte block. The final partial block gets its\n // explicit `1` byte during digestInto(), so `hibit` stays zero there.\n const hibit = isLast ? 0 : 1 << 11;\n const {\n h,\n r\n } = this;\n const r0 = r[0];\n const r1 = r[1];\n const r2 = r[2];\n const r3 = r[3];\n const r4 = r[4];\n const r5 = r[5];\n const r6 = r[6];\n const r7 = r[7];\n const r8 = r[8];\n const r9 = r[9];\n const t0 = u8to16(data, offset + 0);\n const t1 = u8to16(data, offset + 2);\n const t2 = u8to16(data, offset + 4);\n const t3 = u8to16(data, offset + 6);\n const t4 = u8to16(data, offset + 8);\n const t5 = u8to16(data, offset + 10);\n const t6 = u8to16(data, offset + 12);\n const t7 = u8to16(data, offset + 14);\n let h0 = h[0] + (t0 & 0x1fff);\n let h1 = h[1] + ((t0 >>> 13 | t1 << 3) & 0x1fff);\n let h2 = h[2] + ((t1 >>> 10 | t2 << 6) & 0x1fff);\n let h3 = h[3] + ((t2 >>> 7 | t3 << 9) & 0x1fff);\n let h4 = h[4] + ((t3 >>> 4 | t4 << 12) & 0x1fff);\n let h5 = h[5] + (t4 >>> 1 & 0x1fff);\n let h6 = h[6] + ((t4 >>> 14 | t5 << 2) & 0x1fff);\n let h7 = h[7] + ((t5 >>> 11 | t6 << 5) & 0x1fff);\n let h8 = h[8] + ((t6 >>> 8 | t7 << 8) & 0x1fff);\n let h9 = h[9] + (t7 >>> 5 | hibit);\n let c = 0;\n let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6);\n c = d0 >>> 13;\n d0 &= 0x1fff;\n d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1);\n c += d0 >>> 13;\n d0 &= 0x1fff;\n let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7);\n c = d1 >>> 13;\n d1 &= 0x1fff;\n d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2);\n c += d1 >>> 13;\n d1 &= 0x1fff;\n let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8);\n c = d2 >>> 13;\n d2 &= 0x1fff;\n d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3);\n c += d2 >>> 13;\n d2 &= 0x1fff;\n let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9);\n c = d3 >>> 13;\n d3 &= 0x1fff;\n d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4);\n c += d3 >>> 13;\n d3 &= 0x1fff;\n let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;\n c = d4 >>> 13;\n d4 &= 0x1fff;\n d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5);\n c += d4 >>> 13;\n d4 &= 0x1fff;\n let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1;\n c = d5 >>> 13;\n d5 &= 0x1fff;\n d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6);\n c += d5 >>> 13;\n d5 &= 0x1fff;\n let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2;\n c = d6 >>> 13;\n d6 &= 0x1fff;\n d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7);\n c += d6 >>> 13;\n d6 &= 0x1fff;\n let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3;\n c = d7 >>> 13;\n d7 &= 0x1fff;\n d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8);\n c += d7 >>> 13;\n d7 &= 0x1fff;\n let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4;\n c = d8 >>> 13;\n d8 &= 0x1fff;\n d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9);\n c += d8 >>> 13;\n d8 &= 0x1fff;\n let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5;\n c = d9 >>> 13;\n d9 &= 0x1fff;\n d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0;\n c += d9 >>> 13;\n d9 &= 0x1fff;\n c = (c << 2) + c | 0;\n c = c + d0 | 0;\n d0 = c & 0x1fff;\n c = c >>> 13;\n d1 += c;\n h[0] = d0;\n h[1] = d1;\n h[2] = d2;\n h[3] = d3;\n h[4] = d4;\n h[5] = d5;\n h[6] = d6;\n h[7] = d7;\n h[8] = d8;\n h[9] = d9;\n }\n finalize() {\n const {\n h,\n pad\n } = this;\n const g = new Uint16Array(10);\n let c = h[1] >>> 13;\n h[1] &= 0x1fff;\n for (let i = 2; i < 10; i++) {\n h[i] += c;\n c = h[i] >>> 13;\n h[i] &= 0x1fff;\n }\n h[0] += c * 5;\n c = h[0] >>> 13;\n h[0] &= 0x1fff;\n h[1] += c;\n c = h[1] >>> 13;\n h[1] &= 0x1fff;\n h[2] += c;\n // RFC 8439 §2.5 / RFC 7539 §2.5 reduce modulo 2^130-5 before repacking\n // to 16-bit words and adding the raw s half.\n g[0] = h[0] + 5;\n c = g[0] >>> 13;\n g[0] &= 0x1fff;\n for (let i = 1; i < 10; i++) {\n g[i] = h[i] + c;\n c = g[i] >>> 13;\n g[i] &= 0x1fff;\n }\n g[9] -= 1 << 13;\n let mask = (c ^ 1) - 1;\n for (let i = 0; i < 10; i++) g[i] &= mask;\n mask = ~mask;\n for (let i = 0; i < 10; i++) h[i] = h[i] & mask | g[i];\n h[0] = (h[0] | h[1] << 13) & 0xffff;\n h[1] = (h[1] >>> 3 | h[2] << 10) & 0xffff;\n h[2] = (h[2] >>> 6 | h[3] << 7) & 0xffff;\n h[3] = (h[3] >>> 9 | h[4] << 4) & 0xffff;\n h[4] = (h[4] >>> 12 | h[5] << 1 | h[6] << 14) & 0xffff;\n h[5] = (h[6] >>> 2 | h[7] << 11) & 0xffff;\n h[6] = (h[7] >>> 5 | h[8] << 8) & 0xffff;\n h[7] = (h[8] >>> 8 | h[9] << 5) & 0xffff;\n let f = h[0] + pad[0];\n h[0] = f & 0xffff;\n for (let i = 1; i < 8; i++) {\n f = (h[i] + pad[i] | 0) + (f >>> 16) | 0;\n h[i] = f & 0xffff;\n }\n clean(g);\n }\n update(data) {\n aexists(this);\n abytes(data);\n data = copyBytes(data);\n const {\n buffer,\n blockLen\n } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input\n if (take === blockLen) {\n for (; blockLen <= len - pos; pos += blockLen) this.process(data, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(buffer, 0, false);\n this.pos = 0;\n }\n }\n return this;\n }\n destroy() {\n // `aexists(this)` guards update/digest paths, so destroy must mark the instance unusable too.\n this.destroyed = true;\n clean(this.h, this.r, this.buffer, this.pad);\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n const {\n buffer,\n h\n } = this;\n let {\n pos\n } = this;\n if (pos) {\n // RFC 8439 §2.5 / RFC 7539 §2.5: the final short block appends a\n // single `0x01` byte and zero-fills the remaining bytes before the\n // last multiplication step.\n buffer[pos++] = 1;\n for (; pos < 16; pos++) buffer[pos] = 0;\n this.process(buffer, 0, true);\n }\n this.finalize();\n let opos = 0;\n for (let i = 0; i < 8; i++) {\n out[opos++] = h[i] >>> 0;\n out[opos++] = h[i] >>> 8;\n }\n }\n digest() {\n const {\n buffer,\n outputLen\n } = this;\n this.digestInto(buffer);\n // Copy out before destroy() zeroes the internal buffer.\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n}\n// chacha.ts\n/** RFC 8439 §2.3 block core for `state = constants | key | counter | nonce`. */\n// prettier-ignore\nfunction chachaCore(s, k, n, out, cnt, rounds = 20) {\n let y00 = s[0],\n y01 = s[1],\n y02 = s[2],\n y03 = s[3],\n // \"expa\" \"nd 3\" \"2-by\" \"te k\"\n y04 = k[0],\n y05 = k[1],\n y06 = k[2],\n y07 = k[3],\n // Key Key Key Key\n y08 = k[4],\n y09 = k[5],\n y10 = k[6],\n y11 = k[7],\n // Key Key Key Key\n y12 = cnt,\n y13 = n[0],\n y14 = n[1],\n y15 = n[2]; // Counter Nonce Nonce Nonce\n // Save state to temporary variables\n let x00 = y00,\n x01 = y01,\n x02 = y02,\n x03 = y03,\n x04 = y04,\n x05 = y05,\n x06 = y06,\n x07 = y07,\n x08 = y08,\n x09 = y09,\n x10 = y10,\n x11 = y11,\n x12 = y12,\n x13 = y13,\n x14 = y14,\n x15 = y15;\n for (let r = 0; r < rounds; r += 2) {\n x00 = x00 + x04 | 0;\n x12 = rotl(x12 ^ x00, 16);\n x08 = x08 + x12 | 0;\n x04 = rotl(x04 ^ x08, 12);\n x00 = x00 + x04 | 0;\n x12 = rotl(x12 ^ x00, 8);\n x08 = x08 + x12 | 0;\n x04 = rotl(x04 ^ x08, 7);\n x01 = x01 + x05 | 0;\n x13 = rotl(x13 ^ x01, 16);\n x09 = x09 + x13 | 0;\n x05 = rotl(x05 ^ x09, 12);\n x01 = x01 + x05 | 0;\n x13 = rotl(x13 ^ x01, 8);\n x09 = x09 + x13 | 0;\n x05 = rotl(x05 ^ x09, 7);\n x02 = x02 + x06 | 0;\n x14 = rotl(x14 ^ x02, 16);\n x10 = x10 + x14 | 0;\n x06 = rotl(x06 ^ x10, 12);\n x02 = x02 + x06 | 0;\n x14 = rotl(x14 ^ x02, 8);\n x10 = x10 + x14 | 0;\n x06 = rotl(x06 ^ x10, 7);\n x03 = x03 + x07 | 0;\n x15 = rotl(x15 ^ x03, 16);\n x11 = x11 + x15 | 0;\n x07 = rotl(x07 ^ x11, 12);\n x03 = x03 + x07 | 0;\n x15 = rotl(x15 ^ x03, 8);\n x11 = x11 + x15 | 0;\n x07 = rotl(x07 ^ x11, 7);\n x00 = x00 + x05 | 0;\n x15 = rotl(x15 ^ x00, 16);\n x10 = x10 + x15 | 0;\n x05 = rotl(x05 ^ x10, 12);\n x00 = x00 + x05 | 0;\n x15 = rotl(x15 ^ x00, 8);\n x10 = x10 + x15 | 0;\n x05 = rotl(x05 ^ x10, 7);\n x01 = x01 + x06 | 0;\n x12 = rotl(x12 ^ x01, 16);\n x11 = x11 + x12 | 0;\n x06 = rotl(x06 ^ x11, 12);\n x01 = x01 + x06 | 0;\n x12 = rotl(x12 ^ x01, 8);\n x11 = x11 + x12 | 0;\n x06 = rotl(x06 ^ x11, 7);\n x02 = x02 + x07 | 0;\n x13 = rotl(x13 ^ x02, 16);\n x08 = x08 + x13 | 0;\n x07 = rotl(x07 ^ x08, 12);\n x02 = x02 + x07 | 0;\n x13 = rotl(x13 ^ x02, 8);\n x08 = x08 + x13 | 0;\n x07 = rotl(x07 ^ x08, 7);\n x03 = x03 + x04 | 0;\n x14 = rotl(x14 ^ x03, 16);\n x09 = x09 + x14 | 0;\n x04 = rotl(x04 ^ x09, 12);\n x03 = x03 + x04 | 0;\n x14 = rotl(x14 ^ x03, 8);\n x09 = x09 + x14 | 0;\n x04 = rotl(x04 ^ x09, 7);\n }\n // RFC 8439 §2.3 / §2.3.1: add the original state words back in state order.\n let oi = 0;\n out[oi++] = y00 + x00 | 0;\n out[oi++] = y01 + x01 | 0;\n out[oi++] = y02 + x02 | 0;\n out[oi++] = y03 + x03 | 0;\n out[oi++] = y04 + x04 | 0;\n out[oi++] = y05 + x05 | 0;\n out[oi++] = y06 + x06 | 0;\n out[oi++] = y07 + x07 | 0;\n out[oi++] = y08 + x08 | 0;\n out[oi++] = y09 + x09 | 0;\n out[oi++] = y10 + x10 | 0;\n out[oi++] = y11 + x11 | 0;\n out[oi++] = y12 + x12 | 0;\n out[oi++] = y13 + x13 | 0;\n out[oi++] = y14 + x14 | 0;\n out[oi++] = y15 + x15 | 0;\n}\n// prettier-ignore\nfunction hchacha(s, k, i, out) {\n // Runs the shared chachaCore permutation, then subtracts the RFC 8439 feed-forward\n // it applies, recovering the raw permutation words hchacha needs.\n // LE hosts read the caller arrays in place (no copies); BE hosts get\n // byte-swapped scratch copies, wiped before returning.\n const s2 = isLE ? s : swap32IfBE(s.slice(0, 4));\n const k2 = isLE ? k : swap32IfBE(k.slice(0, 8));\n const i2 = isLE ? i : swap32IfBE(i.slice(0, 4));\n const t = new Uint32Array(16);\n chachaCore(s2, k2, i2.subarray(1), t, i2[0]);\n let oi = 0;\n out[oi++] = t[0] - s2[0] | 0;\n out[oi++] = t[1] - s2[1] | 0;\n out[oi++] = t[2] - s2[2] | 0;\n out[oi++] = t[3] - s2[3] | 0;\n out[oi++] = t[12] - i2[0] | 0;\n out[oi++] = t[13] - i2[1] | 0;\n out[oi++] = t[14] - i2[2] | 0;\n out[oi++] = t[15] - i2[3] | 0;\n swap32IfBE(out);\n if (!isLE) clean(s2, k2, i2);\n clean(t);\n}\nconst chacha20 = /* @__PURE__ */createCipher(chachaCore, {\n counterRight: false,\n counterLength: 4,\n allowShortKeys: false\n});\nconst xchacha20 = /* @__PURE__ */createCipher(chachaCore, {\n counterRight: false,\n counterLength: 8,\n extendNonceFn: hchacha,\n allowShortKeys: false\n});\n// RFC 8439 §2.8.1 pad16(x): shared zero block for AAD/ciphertext padding.\nconst ZEROS16 = /* @__PURE__ */new Uint8Array(16);\n// RFC 8439 §2.8 / §2.8.1: aligned inputs add nothing, otherwise append 16-(len%16) zero bytes.\nconst updatePadded = (h, msg) => {\n h.update(msg);\n const leftover = msg.length % 16;\n if (leftover) h.update(ZEROS16.subarray(leftover));\n};\n// RFC 8439 §2.6.1 poly1305_key_gen returns `block[0..31]`, so AEAD key\n// generation only needs 32 zero bytes.\nconst ZEROS32 = /* @__PURE__ */new Uint8Array(32);\nfunction computeTag(fn, key, nonce, ciphertext, AAD) {\n if (AAD !== undefined) abytes(AAD, undefined, \"AAD\");\n // RFC 8439 §2.6 / §2.8: derive the Poly1305 one-time key from counter 0,\n // then MAC AAD || pad16(AAD) || ciphertext || pad16(ciphertext) || len(AAD) || len(ciphertext).\n const authKey = fn(key, nonce, ZEROS32);\n const lengths = u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true);\n // Methods below can be replaced with\n // `return poly1305_computeTag_small(authKey, lengths, ciphertext, AAD)`\n // from `test/misc/micro-ciphers.ts`.\n const h = new Poly1305(authKey);\n if (AAD) updatePadded(h, AAD);\n updatePadded(h, ciphertext);\n h.update(lengths);\n const res = h.digest();\n clean(authKey, lengths);\n return res;\n}\n/**\n * AEAD algorithm from RFC 8439.\n * Salsa20 and chacha (RFC 8439) use poly1305 differently.\n * We could have composed them, but it's hard because of authKey:\n * In salsa20, authKey changes position in salsa stream.\n * In chacha, authKey can't be computed inside computeTag, it modifies the counter.\n */\nconst _poly1305_aead = xorStream => (key, nonce, AAD) => {\n // This borrows caller key/nonce/AAD buffers by reference; mutating them after construction\n // changes future encrypt/decrypt results.\n const tagLength = 16;\n return {\n encrypt(plaintext, output) {\n const plength = plaintext.length;\n output = getOutput(plength + tagLength, output, false);\n output.set(plaintext);\n const oPlain = output.subarray(0, -tagLength);\n // RFC 8439 §2.8: payload encryption starts at counter 1 because counter 0 produced the OTK.\n xorStream(key, nonce, oPlain, oPlain, 1);\n const tag = computeTag(xorStream, key, nonce, oPlain, AAD);\n output.set(tag, plength); // append tag\n clean(tag);\n return output;\n },\n decrypt(ciphertext, output) {\n output = getOutput(ciphertext.length - tagLength, output, false);\n const data = ciphertext.subarray(0, -tagLength);\n const passedTag = ciphertext.subarray(-tagLength);\n const tag = computeTag(xorStream, key, nonce, data, AAD);\n // RFC 8439 §2.8 / §4: authenticate ciphertext before decrypting it, and compare tags with\n // the constant-time equalBytes() helper rather than decrypting speculative plaintext first.\n if (!equalBytes(passedTag, tag)) {\n clean(tag);\n return undefined;\n }\n output.set(ciphertext.subarray(0, -tagLength));\n // Actual decryption\n xorStream(key, nonce, output, output, 1); // start stream with i=1\n clean(tag);\n return output;\n }\n };\n};\n/**\n * ChaCha20-Poly1305 from RFC 8439, with a 32-byte key and a 12-byte nonce.\n *\n * @internal\n */\nexport const chacha20Poly1305 = /* @__PURE__ */_poly1305_aead(chacha20);\n/**\n * XChaCha20-Poly1305 from draft-irtf-cfrg-xchacha-03, with a 32-byte key and a\n * 24-byte nonce.\n *\n * @internal\n */\nexport const xchacha20Poly1305 = /* @__PURE__ */_poly1305_aead(xchacha20);\n//# sourceMappingURL=chacha.js.map",
|
|
13
|
+
"import * as Effect from \"../../Effect.js\";\nimport * as Predicate from \"../../Predicate.js\";\nimport * as CryptoError from \"../CryptoError.js\";\nimport { WebCrypto } from \"../WebCrypto.js\";\n/** @internal */\nexport const subtleUnavailable = () => new Error(\"crypto.subtle is unavailable; browsers expose it only in secure contexts\");\n/** @internal */\nexport const fail = (module, method, reason) => Effect.fail(new CryptoError.CryptoError({\n module,\n method,\n reason\n}));\n/** @internal */\nexport const invalidKey = (module, method, description) => fail(module, method, new CryptoError.InvalidKey({\n description\n}));\n/** @internal */\nexport const notExtractable = (module, method) => fail(module, method, new CryptoError.NotExtractable({\n description: \"The CryptoKey is not extractable\"\n}));\n/**\n * Moves an error raised by another module's function onto `module.method`.\n *\n * @internal\n */\nexport const rehome = (module, method) => error => fail(module, method, error.reason);\n/**\n * Thrown inside {@link run} to fail with a typed reason instead of a defect,\n * for checks that need the imported `CryptoKey`.\n *\n * @internal\n */\nexport class Failure {\n reason;\n constructor(reason) {\n this.reason = reason;\n }\n}\n/** @internal */\nexport const isOperationError = cause => Predicate.hasProperty(cause, \"name\") && cause.name === \"OperationError\";\n/**\n * Maps an exception thrown by `crypto.subtle` in `module.layerWebCrypto` to a\n * `CryptoError`.\n *\n * A {@link Failure} carries its own reason. `DataError` and\n * `InvalidAccessError` are `InvalidKey`, and `NotSupportedError` is\n * `Unsupported`, naming the algorithm and the layer. An `OperationError`\n * becomes the reason from `onOperationError`, such as `DecryptionFailed` for a\n * decryption. Any other exception is rethrown, which `Effect.tryPromise` turns\n * into a defect.\n *\n * @internal\n */\nexport const webCryptoError = (module, method, algorithm, cause, onOperationError) => toCryptoError(module, method, `${module}.layerWebCrypto`, algorithm, cause, onOperationError);\nconst toCryptoError = (module, method, provider, algorithm, cause, onOperationError) => {\n const reason = reasonFor(method, provider, algorithm, cause, onOperationError);\n if (reason === undefined) throw cause;\n return new CryptoError.CryptoError({\n module,\n method,\n reason\n });\n};\nconst reasonFor = (method, provider, algorithm, cause, onOperationError) => {\n if (cause instanceof Failure) return cause.reason;\n switch (Predicate.hasProperty(cause, \"name\") ? cause.name : undefined) {\n case \"DataError\":\n return new CryptoError.InvalidKey({\n description: \"Invalid key data\",\n cause\n });\n case \"InvalidAccessError\":\n return new CryptoError.InvalidKey({\n description: `The key cannot be used for ${method}`,\n cause\n });\n case \"NotSupportedError\":\n return new CryptoError.Unsupported({\n description: `${provider} does not provide ${algorithm}`,\n cause\n });\n case \"OperationError\":\n return onOperationError?.();\n default:\n return undefined;\n }\n};\n/**\n * Runs `f` on the `subtle` of a `Crypto` object in `module.layerWebCrypto`,\n * dying when it is missing, as in an insecure browser context. Exceptions go\n * through `onError`, which defaults to {@link webCryptoError}.\n *\n * @internal\n */\nexport const run = (module, method, algorithm, crypto, f, onError = cause => webCryptoError(module, method, algorithm, cause)) => Effect.suspend(() => {\n const subtle = crypto?.subtle;\n if (subtle === undefined) return Effect.die(subtleUnavailable());\n return Effect.tryPromise({\n try: () => f(subtle),\n catch: onError\n });\n});\n/**\n * {@link run} on the `WebCrypto` reference, for the top-level functions that\n * have no layer to read it from. `crypto.subtle` is named as the provider\n * that declined an algorithm.\n *\n * @internal\n */\nexport const runWithReference = (module, method, algorithm, f) => WebCrypto.use(crypto => run(module, method, algorithm, crypto, f, cause => toCryptoError(module, method, \"crypto.subtle\", algorithm, cause)));\n//# sourceMappingURL=webCrypto.js.map",
|
|
14
|
+
"import * as Effect from \"../../Effect.js\";\nimport * as Equal from \"../../Equal.js\";\nimport { format } from \"../../Formatter.js\";\nimport { NodeInspectSymbol } from \"../../Inspectable.js\";\nimport * as Predicate from \"../../Predicate.js\";\nimport * as internal from \"./webCrypto.js\";\n/**\n * The property holding a key's material. Only this package reads it: platform\n * layers pass primitives to a family's `layerWebCryptoWith` instead, and\n * third-party layers use the family's public `toBytes`.\n *\n * This is not a secrecy mechanism. Being non-enumerable keeps the material out\n * of `JSON.stringify` and `inspect`, but anyone holding a key can reach it\n * through `Object.getOwnPropertySymbols`.\n *\n * @internal\n */\nexport const MaterialId = /*#__PURE__*/Symbol(\"~effect/crypto/Key/material\");\n/**\n * Copies bytes into a plain `Uint8Array` with its own buffer. A subclass's\n * `slice` may not copy: a Node.js `Buffer`'s returns a view of the same memory.\n *\n * @internal\n */\nexport const copyBytes = bytes => new Uint8Array(bytes);\n/** @internal */\nexport const material = key => key[MaterialId];\n/**\n * Builds a key prototype that displays only its algorithm.\n *\n * @internal\n */\nexport const redactedProto = (typeId, label) => ({\n [typeId]: typeId,\n toJSON() {\n return {\n _id: label,\n algorithm: this.algorithm.name\n };\n },\n toString() {\n return format(this.toJSON());\n },\n [NodeInspectSymbol]() {\n return this.toJSON();\n }\n});\n/**\n * Builds a key. Keys compare by reference: comparing key bytes is not constant\n * time, and structural equality would let secret keys act as `HashMap` keys.\n */\nconst make = (proto, algorithm, material) => Equal.byReferenceUnsafe(Object.create(proto, {\n algorithm: {\n value: algorithm,\n enumerable: true\n },\n [MaterialId]: {\n value: material\n }\n}));\n/** @internal */\nexport const makeBytes = (proto, algorithm, bytes) => make(proto, algorithm, {\n _tag: \"Bytes\",\n bytes\n});\n/**\n * Checks the length of a symmetric key against its algorithm.\n *\n * @internal\n */\nexport const checkKeyLength = algorithm => bytes => bytes.length === algorithm.keyLength ? undefined : `Expected a ${algorithm.keyLength}-byte key for ${algorithm.name}, not ${bytes.length} bytes`;\n/**\n * Copies raw key bytes into a byte-backed key, rejecting other values and\n * bytes that fail `check`.\n *\n * @internal\n */\nexport const fromBytes = (module, method, proto, algorithm, bytes, check) => Effect.suspend(() => {\n if (!(bytes instanceof Uint8Array)) return internal.invalidKey(module, method, \"Expected the key as a Uint8Array\");\n const problem = check(bytes);\n return problem === undefined ? Effect.succeed(makeBytes(proto, algorithm, copyBytes(bytes))) : internal.invalidKey(module, method, problem);\n});\n/**\n * Checks that an AES `CryptoKey` has the algorithm's length.\n *\n * @internal\n */\nexport const checkAesLength = (name, keyLength) => algorithm => {\n const length = algorithm.length;\n return length === keyLength * 8 ? undefined : `Expected a ${keyLength * 8}-bit ${name} key, not ${length} bits`;\n};\nconst checkCryptoKey = (cryptoKey, expected) => {\n if (!Predicate.hasProperty(cryptoKey, \"type\") || !Predicate.hasProperty(cryptoKey, \"algorithm\") || !Predicate.hasProperty(cryptoKey, \"usages\") || !Array.isArray(cryptoKey.usages)) {\n return \"Expected a CryptoKey\";\n }\n if (cryptoKey.algorithm.name !== expected.name) {\n return `Expected a ${expected.name} key, not ${cryptoKey.algorithm.name}`;\n }\n if (cryptoKey.type !== expected.type) return `Expected a ${expected.type} key, not ${cryptoKey.type}`;\n const problem = expected.check?.(cryptoKey.algorithm);\n if (problem !== undefined) return problem;\n const usages = cryptoKey.usages;\n if (expected.usagePolicy === \"all\") {\n if (!expected.usages.every(usage => usages.includes(usage))) {\n return `Expected a key with the usages ${expected.usages.join(\" and \")}, not ${usages.join(\", \") || \"none\"}`;\n }\n } else if (!expected.usages.some(usage => usages.includes(usage))) {\n return `Expected a key with one of the usages ${expected.usages.join(\", \")}`;\n }\n return undefined;\n};\n/**\n * The algorithm of a key imported from `cryptoKey`. An RSA algorithm's\n * `modulusLength` is only read by key generation, so the key reports the real\n * size of `cryptoKey` instead.\n *\n * @internal\n */\nexport const importedAlgorithm = (algorithm, cryptoKey) => {\n const modulusLength = cryptoKey.algorithm.modulusLength;\n return Predicate.hasProperty(algorithm, \"modulusLength\") && modulusLength !== undefined && algorithm.modulusLength !== modulusLength ? {\n ...algorithm,\n modulusLength\n } : algorithm;\n};\n/**\n * Synchronously validates and wraps a `CryptoKey`. The structural key only\n * becomes the native `CryptoKey` once it passes the check.\n *\n * @internal\n */\nexport const fromCryptoKey = (module, method, proto, algorithm, cryptoKey, expected) => Effect.suspend(() => {\n const problem = checkCryptoKey(cryptoKey, expected);\n return problem === undefined ? Effect.succeed(make(proto, importedAlgorithm(algorithm, cryptoKey), {\n _tag: \"CryptoKey\",\n cryptoKey: cryptoKey\n })) : internal.invalidKey(module, method, problem);\n});\n/** @internal */\nexport const exportRaw = async (subtle, cryptoKey) => new Uint8Array(await subtle.exportKey(\"raw\", cryptoKey));\n/**\n * Exports a key's stored representation as fresh bytes. `CryptoKey`-backed\n * keys are exported on the `WebCrypto` reference with `exportKey`.\n *\n * @internal\n */\nexport const toBytes = (module, key, exportKey) => Effect.suspend(() => {\n const stored = material(key);\n if (stored._tag === \"Bytes\") return Effect.succeed(copyBytes(stored.bytes));\n if (!stored.cryptoKey.extractable) return internal.notExtractable(module, \"toBytes\");\n return internal.runWithReference(module, \"toBytes\", key.algorithm.name, subtle => exportKey(subtle, stored.cryptoKey));\n});\n/**\n * A per-layer cache of the `CryptoKey`s imported from byte-backed keys.\n *\n * @internal\n */\nexport const makeCache = importKey => {\n const cache = new WeakMap();\n return async (subtle, key) => {\n const stored = material(key);\n if (stored._tag === \"CryptoKey\") return stored.cryptoKey;\n let cryptoKey = cache.get(key);\n if (cryptoKey === undefined) {\n cryptoKey = await importKey(subtle, stored.bytes, key.algorithm);\n cache.set(key, cryptoKey);\n }\n return cryptoKey;\n };\n};\n//# sourceMappingURL=key.js.map",
|
|
15
|
+
"/**\n * Authenticated encryption: AES-GCM, ChaCha20-Poly1305, and\n * XChaCha20-Poly1305.\n *\n * The {@link Aead} service generates keys, encrypts, and decrypts. The\n * top-level {@link key}, {@link fromCryptoKey}, and {@link toBytes} functions\n * build and export keys without a service.\n *\n * Ciphertext is `ciphertext‖tag` with a 16-byte tag for every algorithm, the\n * layout WebCrypto produces. A tampered ciphertext, tag, or additional data\n * fails decryption with a `DecryptionFailed` reason that carries no detail.\n *\n * AES-GCM runs on `crypto.subtle`. ChaCha20-Poly1305 and XChaCha20-Poly1305\n * run a pure TypeScript implementation vendored from `@noble/ciphers` 2.4.0,\n * because WebCrypto does not provide them everywhere. Cure53 audited\n * `@noble/ciphers` 1.0.0 in 2024.\n *\n * Keys are opaque. They hold either key bytes or, for AES-GCM, a `CryptoKey`,\n * display only their algorithm, and compare by reference.\n *\n * **Gotchas**\n *\n * Never reuse a nonce with the same key. Random 12-byte nonces risk a\n * collision after about 2^32 messages under one key: use a counter, or\n * XChaCha20-Poly1305, whose 24-byte nonces can be random.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as Chacha from \"./internal/chacha.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst TypeId = \"~effect/crypto/Aead/Key\";\n/**\n * AES-128-GCM, with a 16-byte key and a 12-byte nonce.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes128Gcm = {\n name: \"aes128Gcm\",\n keyLength: 16,\n nonceLength: 12,\n implementation: undefined\n};\n/**\n * AES-256-GCM, with a 32-byte key and a 12-byte nonce.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes256Gcm = {\n name: \"aes256Gcm\",\n keyLength: 32,\n nonceLength: 12,\n implementation: undefined\n};\nconst chachaImplementation = aead => ({\n encrypt: (key, nonce, plaintext, aad) => aead(key, nonce, aad).encrypt(plaintext),\n decrypt: (key, nonce, ciphertext, aad) => aead(key, nonce, aad).decrypt(ciphertext)\n});\n/**\n * ChaCha20-Poly1305 (RFC 8439), with a 32-byte key and a 12-byte nonce.\n *\n * **Details**\n *\n * Runs the pure TypeScript implementation under `layerWebCrypto`, even where\n * `crypto.subtle` provides it, so every runtime takes one code path.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const chacha20Poly1305 = {\n name: \"chacha20Poly1305\",\n keyLength: 32,\n nonceLength: 12,\n implementation: /* @__PURE__ */chachaImplementation(Chacha.chacha20Poly1305)\n};\n/**\n * XChaCha20-Poly1305 (draft-irtf-cfrg-xchacha-03), with a 32-byte key and a\n * 24-byte nonce.\n *\n * **When to use**\n *\n * Use when nonces are generated randomly, since 24-byte nonces make\n * collisions negligible. The output is compatible with libsodium's\n * `crypto_aead_xchacha20poly1305_ietf`.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const xchacha20Poly1305 = {\n name: \"xchacha20Poly1305\",\n keyLength: 32,\n nonceLength: 24,\n implementation: /* @__PURE__ */chachaImplementation(Chacha.xchacha20Poly1305)\n};\nconst KeyProto = /*#__PURE__*/KeyModel.redactedProto(TypeId, \"Aead.Key\");\n/**\n * Checks whether a value is a {@link Key}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isKey = u => Predicate.hasProperty(u, TypeId);\n/**\n * Service that generates keys, encrypts, and decrypts with authentication.\n *\n * **Example** (Encrypting with XChaCha20-Poly1305)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { Aead, SecureRandom } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const aead = yield* Aead.Aead\n * const random = yield* SecureRandom.SecureRandom\n * const key = yield* aead.generateKey(Aead.xchacha20Poly1305)\n * const nonce = yield* random.randomBytes(24)\n * const sealed = yield* aead.encrypt(key, new TextEncoder().encode(\"secret\"), { nonce })\n * const opened = yield* aead.decrypt(key, sealed, { nonce })\n * return [sealed.length, new TextDecoder().decode(opened)]\n * })\n *\n * const layer = Aead.layerWebCrypto.pipe(Layer.provideMerge(SecureRandom.layerWebCrypto))\n * await Effect.runPromise(program.pipe(Effect.provide(layer))) // => [22, \"secret\"]\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Aead extends /*#__PURE__*/Context.Service()(\"effect/crypto/Aead\") {}\nconst fail = (method, reason) => internal.fail(\"Aead\", method, reason);\nconst decryptionFailed = () => fail(\"decrypt\", new CryptoError.DecryptionFailed());\n// GCM limits the plaintext to 2^39 - 256 bits.\nconst maxGcmPlaintext = 2 ** 36 - 32;\nconst tagLength = 16;\n// Every check runs before any work, so the pure TypeScript code only throws on\n// a bug, and WebCrypto's `OperationError` only means a failed tag check.\nconst checkArguments = (method, key, data, options) => {\n const algorithm = key.algorithm;\n if (options.nonce.length !== algorithm.nonceLength) {\n return fail(method, new CryptoError.InvalidArgument({\n description: `${algorithm.name} nonces must contain exactly ${algorithm.nonceLength} bytes`\n }));\n }\n if (method === \"encrypt\") {\n if (algorithm.implementation === undefined && data.length > maxGcmPlaintext) {\n return fail(method, new CryptoError.InvalidArgument({\n description: \"AES-GCM plaintext cannot exceed 2^36 - 32 bytes\"\n }));\n }\n } else if (data.length < tagLength) {\n return decryptionFailed();\n }\n return undefined;\n};\nconst runImplementation = (method, implementation, key, data, options) => {\n const stored = KeyModel.material(key);\n if (stored._tag !== \"Bytes\") {\n return fail(method, new CryptoError.InvalidKey({\n description: `${key.algorithm.name} keys must hold bytes`\n }));\n }\n const aad = options.aad ?? new Uint8Array(0);\n if (method === \"encrypt\") {\n return Effect.sync(() => implementation.encrypt(stored.bytes, options.nonce, data, aad));\n }\n return Effect.suspend(() => {\n const plaintext = implementation.decrypt(stored.bytes, options.nonce, data, aad);\n return plaintext === undefined ? decryptionFailed() : Effect.succeed(plaintext);\n });\n};\n/**\n * Builds an `Aead` layer on the `WebCrypto` reference that runs the given\n * implementations for byte-backed keys.\n *\n * **When to use**\n *\n * Use to run an algorithm on a runtime's native code, as `NodeCrypto.layerAead`\n * does for ChaCha20-Poly1305 with `node:crypto`.\n *\n * **Details**\n *\n * `implementations` maps algorithm names to implementations that replace\n * `crypto.subtle` or the algorithm's pure TypeScript code. They follow the\n * {@link Implementation} contract and run only for byte-backed keys, after the\n * layer has checked the nonce, plaintext, and ciphertext lengths, so errors are\n * those of {@link layerWebCrypto}. `CryptoKey`-backed keys run on\n * `crypto.subtle`, and generated keys come from `SecureRandom`. Without\n * `implementations`, the layer is {@link layerWebCrypto}.\n *\n * **Gotchas**\n *\n * An implementation receives the key's own bytes, not a copy, so it must not\n * modify or keep them.\n *\n * **Example** (Running ChaCha20-Poly1305 natively)\n *\n * ```ts\n * import { Layer } from \"effect\"\n * import { Aead, SecureRandom } from \"effect/crypto\"\n *\n * declare const nativeChacha: Aead.Implementation\n *\n * const layer = Aead.layerWebCryptoWith({\n * implementations: { chacha20Poly1305: nativeChacha }\n * }).pipe(Layer.provide(SecureRandom.layerWebCrypto))\n * ```\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCryptoWith = options => Layer.effect(Aead, Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const cryptoKeyFor = KeyModel.makeCache((subtle, bytes) => subtle.importKey(\"raw\", bytes, \"AES-GCM\", false, [\"encrypt\", \"decrypt\"]));\n const implementations = options.implementations;\n // A supplied implementation runs only for byte-backed keys, so CryptoKeys\n // stay on `crypto.subtle`.\n const implementationFor = key => {\n const supplied = implementations?.[key.algorithm.name];\n return supplied !== undefined && KeyModel.material(key)._tag === \"Bytes\" ? supplied : key.algorithm.implementation;\n };\n const gcm = (method, key, data, options) => {\n const params = {\n name: \"AES-GCM\",\n iv: options.nonce,\n tagLength: 128,\n ...(options.aad === undefined ? {} : {\n additionalData: options.aad\n })\n };\n return internal.run(\"Aead\", method, key.algorithm.name, crypto, async subtle => new Uint8Array(await subtle[method](params, await cryptoKeyFor(subtle, key), data)), cause => internal.webCryptoError(\"Aead\", method, key.algorithm.name, cause, method === \"decrypt\" ? () => new CryptoError.DecryptionFailed() : undefined));\n };\n const run = method => (key, data, options) => Effect.suspend(() => {\n const failure = checkArguments(method, key, data, options);\n if (failure !== undefined) return failure;\n const implementation = implementationFor(key);\n return implementation === undefined ? gcm(method, key, data, options) : runImplementation(method, implementation, key, data, options);\n });\n return Aead.of({\n generateKey: algorithm => Effect.map(random.randomBytes(algorithm.keyLength), bytes => KeyModel.makeBytes(KeyProto, algorithm, bytes)),\n encrypt: run(\"encrypt\"),\n decrypt: run(\"decrypt\")\n });\n}));\n/**\n * Layer that provides `Aead` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * AES-GCM runs on `crypto.subtle`. The layer imports a byte-backed key on\n * first use and caches the `CryptoKey`. ChaCha20-Poly1305 and\n * XChaCha20-Poly1305 always run the pure TypeScript implementation, with no\n * feature detection. Generated keys come from `SecureRandom`, so a seeded\n * `SecureRandom` gives reproducible keys.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/layerWebCryptoWith({});\n/**\n * Builds a key from raw key bytes.\n *\n * **Details**\n *\n * Copies the bytes, including Node.js `Buffer` inputs. A length other than\n * the algorithm's key length fails with an `InvalidKey` reason. AES-192 is\n * not supported.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const key = (algorithm, bytes) => KeyModel.fromBytes(\"Aead\", \"key\", KeyProto, algorithm, bytes, KeyModel.checkKeyLength(algorithm));\n/**\n * Builds an AES-GCM key from an existing `CryptoKey`, such as a\n * non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a secret AES-GCM key of the algorithm's length with\n * both the `encrypt` and `decrypt` usages, since a key reaches both\n * operations. Otherwise the constructor fails with an `InvalidKey` reason. It\n * must come from the `Crypto` object of the `WebCrypto` reference.\n *\n * ChaCha20-Poly1305 and XChaCha20-Poly1305 never run on `crypto.subtle`, so\n * passing them is a type error.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromCryptoKey = (algorithm, cryptoKey) => algorithm.implementation !== undefined ? internal.invalidKey(\"Aead\", \"fromCryptoKey\", `${algorithm.name} keys cannot be CryptoKeys`) : KeyModel.fromCryptoKey(\"Aead\", \"fromCryptoKey\", KeyProto, algorithm, cryptoKey, {\n type: \"secret\",\n name: \"AES-GCM\",\n usages: [\"encrypt\", \"decrypt\"],\n usagePolicy: \"all\",\n check: KeyModel.checkAesLength(\"AES-GCM\", algorithm.keyLength)\n});\n/**\n * Exports a key's bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array` that shares no memory with the key. A\n * `CryptoKey`-backed key is exported on the `WebCrypto` reference, and fails\n * with a `NotExtractable` reason when the `CryptoKey` is not extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => KeyModel.toBytes(\"Aead\", key, KeyModel.exportRaw);\n//# sourceMappingURL=Aead.js.map",
|
|
16
|
+
"/**\n * Unauthenticated encryption with no integrity: compose with `Mac`.\n *\n * AES-CTR and AES-CBC with PKCS#7 padding, for protocols that pair them with a\n * MAC, such as SSH, SRTP, JWE, CMS, and Matrix. Anyone can change the\n * ciphertext without being detected, so authenticate it with `Mac`\n * (encrypt-then-MAC), or use `Aead` instead.\n *\n * The {@link Cipher} service generates keys, encrypts, and decrypts. The\n * top-level {@link key}, {@link fromCryptoKey}, and {@link toBytes} functions\n * build and export keys without a service. Both modes run on `crypto.subtle`.\n *\n * Keys are opaque. They hold either key bytes or a `CryptoKey`, display only\n * their algorithm, and compare by reference.\n *\n * **Gotchas**\n *\n * - Never reuse an IV with the same key. For AES-CTR a repeated counter block\n * reveals the XOR of two plaintexts. For AES-CBC the IV must also be\n * unpredictable.\n * - AES-CTR decryption never fails, whatever the ciphertext. AES-CBC\n * decryption fails with one `DecryptionFailed` reason for both bad padding\n * and a bad length, so callers cannot tell them apart. Verify a MAC before\n * decrypting, or the error itself becomes a padding oracle.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst TypeId = \"~effect/crypto/Cipher/Key\";\n/**\n * AES-128-CTR, with a 16-byte key.\n *\n * **Details**\n *\n * The 16-byte `iv` is the initial counter block, and the whole 128-bit block\n * is the counter, as in OpenSSL, Node.js, Go's `cipher.NewCTR`, and noble.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes128Ctr = {\n name: \"aes128Ctr\",\n mode: \"AES-CTR\",\n keyLength: 16\n};\n/**\n * AES-256-CTR, with a 32-byte key.\n *\n * **Details**\n *\n * The 16-byte `iv` is the initial counter block, and the whole 128-bit block\n * is the counter, as in OpenSSL, Node.js, Go's `cipher.NewCTR`, and noble.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes256Ctr = {\n name: \"aes256Ctr\",\n mode: \"AES-CTR\",\n keyLength: 32\n};\n/**\n * AES-128-CBC with PKCS#7 padding, with a 16-byte key.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes128Cbc = {\n name: \"aes128Cbc\",\n mode: \"AES-CBC\",\n keyLength: 16\n};\n/**\n * AES-256-CBC with PKCS#7 padding, with a 32-byte key.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes256Cbc = {\n name: \"aes256Cbc\",\n mode: \"AES-CBC\",\n keyLength: 32\n};\nconst KeyProto = /*#__PURE__*/KeyModel.redactedProto(TypeId, \"Cipher.Key\");\n/**\n * Checks whether a value is a {@link Key}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isKey = u => Predicate.hasProperty(u, TypeId);\n/**\n * Service that generates keys, encrypts, and decrypts without\n * authentication.\n *\n * **Example** (Encrypting with AES-CBC)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { Cipher, SecureRandom } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const cipher = yield* Cipher.Cipher\n * const random = yield* SecureRandom.SecureRandom\n * const key = yield* cipher.generateKey(Cipher.aes256Cbc)\n * const iv = yield* random.randomBytes(16)\n * const ciphertext = yield* cipher.encrypt(key, new TextEncoder().encode(\"secret\"), { iv })\n * const plaintext = yield* cipher.decrypt(key, ciphertext, { iv })\n * return [ciphertext.length, new TextDecoder().decode(plaintext)]\n * })\n *\n * const layer = Cipher.layerWebCrypto.pipe(Layer.provideMerge(SecureRandom.layerWebCrypto))\n * await Effect.runPromise(program.pipe(Effect.provide(layer))) // => [16, \"secret\"]\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Cipher extends /*#__PURE__*/Context.Service()(\"effect/crypto/Cipher\") {}\nconst fail = (method, reason) => internal.fail(\"Cipher\", method, reason);\nconst blockLength = 16;\nconst params = (algorithm, iv) => algorithm.mode === \"AES-CTR\" ? {\n name: \"AES-CTR\",\n counter: iv,\n length: 128\n} : {\n name: \"AES-CBC\",\n iv: iv\n};\n/**\n * Layer that provides `Cipher` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * Encryption and decryption run on `crypto.subtle`. The layer imports a\n * byte-backed key on first use and caches the `CryptoKey`. AES-CTR uses the\n * whole 128-bit block as the counter (`length: 128`), which every runtime\n * supports. Generated keys come from `SecureRandom`, so a seeded\n * `SecureRandom` gives reproducible keys.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(Cipher, /*#__PURE__*/Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const cryptoKeyFor = KeyModel.makeCache((subtle, bytes, algorithm) => subtle.importKey(\"raw\", bytes, algorithm.mode, false, [\"encrypt\", \"decrypt\"]));\n const run = method => (key, data, options) => Effect.suspend(() => {\n if (options.iv.length !== blockLength) {\n return fail(method, new CryptoError.InvalidArgument({\n description: \"IVs must contain exactly 16 bytes\"\n }));\n }\n // Checked here so a bad length is not reported differently from bad padding.\n const cbc = key.algorithm.mode === \"AES-CBC\";\n if (method === \"decrypt\" && cbc && (data.length === 0 || data.length % blockLength !== 0)) {\n return fail(method, new CryptoError.DecryptionFailed());\n }\n return internal.run(\"Cipher\", method, key.algorithm.name, crypto, async subtle => new Uint8Array(await subtle[method](params(key.algorithm, options.iv), await cryptoKeyFor(subtle, key), data)), cause => internal.webCryptoError(\"Cipher\", method, key.algorithm.name, cause, method === \"decrypt\" && cbc ? () => new CryptoError.DecryptionFailed() : undefined));\n });\n return Cipher.of({\n generateKey: algorithm => Effect.map(random.randomBytes(algorithm.keyLength), bytes => KeyModel.makeBytes(KeyProto, algorithm, bytes)),\n encrypt: run(\"encrypt\"),\n decrypt: run(\"decrypt\")\n });\n}));\n/**\n * Builds a key from raw key bytes.\n *\n * **Details**\n *\n * Copies the bytes, including Node.js `Buffer` inputs. A length other than\n * the algorithm's key length fails with an `InvalidKey` reason. AES-192 is\n * not supported.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const key = (algorithm, bytes) => KeyModel.fromBytes(\"Cipher\", \"key\", KeyProto, algorithm, bytes, KeyModel.checkKeyLength(algorithm));\n/**\n * Builds a key from an existing `CryptoKey`, such as a non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a secret key for the algorithm's mode (`AES-CTR` or\n * `AES-CBC`) and length, with both the `encrypt` and `decrypt` usages, since\n * a key reaches both operations. Otherwise the constructor fails with an\n * `InvalidKey` reason. It must come from the `Crypto` object of the\n * `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromCryptoKey = (algorithm, cryptoKey) => KeyModel.fromCryptoKey(\"Cipher\", \"fromCryptoKey\", KeyProto, algorithm, cryptoKey, {\n type: \"secret\",\n name: algorithm.mode,\n usages: [\"encrypt\", \"decrypt\"],\n usagePolicy: \"all\",\n check: KeyModel.checkAesLength(algorithm.mode, algorithm.keyLength)\n});\n/**\n * Exports a key's bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array` that shares no memory with the key. A\n * `CryptoKey`-backed key is exported on the `WebCrypto` reference, and fails\n * with a `NotExtractable` reason when the `CryptoKey` is not extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => KeyModel.toBytes(\"Cipher\", key, KeyModel.exportRaw);\n//# sourceMappingURL=Cipher.js.map",
|
|
17
|
+
"import * as Effect from \"../../Effect.js\";\nimport * as Predicate from \"../../Predicate.js\";\nimport * as CryptoError from \"../CryptoError.js\";\nimport * as KeyModel from \"./key.js\";\nimport * as internal from \"./webCrypto.js\";\n// RFC 8410: the PKCS#8 encoding of a 32-byte Ed25519 or X25519 private key is\n// this prefix, ending in the algorithm's OID byte, followed by the key.\nconst seedPrefix = oid => Uint8Array.of(48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, oid, 4, 34, 4, 32);\n/** @internal */\nexport const ed25519Prefix = /*#__PURE__*/seedPrefix(112);\n/** @internal */\nexport const x25519Prefix = /*#__PURE__*/seedPrefix(110);\nconst seedLength = 32;\n/**\n * Coordinate sizes in bytes, which are also the sizes of an ECDSA signature's\n * `r` and `s` and of an ECDH shared secret.\n *\n * @internal\n */\nexport const coordinateSizes = {\n \"P-256\": 32,\n \"P-384\": 48,\n \"P-521\": 66\n};\n/**\n * Checks raw Ed25519 or X25519 key length, with guidance for 64-byte seeds.\n *\n * @internal\n */\nexport const checkSeedLength = (name, role) => bytes => {\n if (bytes.length === seedLength) return undefined;\n if (role === \"private\" && bytes.length === 64) {\n return `Expected the 32-byte ${name} seed, not the 64-byte seed‖public key form: pass its first 32 bytes`;\n }\n return `Expected a ${seedLength}-byte ${name} ${role} key, not ${bytes.length} bytes`;\n};\n/**\n * Checks the encoding of a raw EC public key: an uncompressed SEC1 point,\n * `0x04` followed by both coordinates. Whether the point is on the curve is\n * checked when the key is first used.\n *\n * @internal\n */\nexport const checkPoint = curve => bytes => {\n const length = 1 + 2 * coordinateSizes[curve];\n if (bytes.length !== length) return `Expected a ${length}-byte uncompressed ${curve} point, not ${bytes.length} bytes`;\n return bytes[0] === 4 ? undefined : `Expected an uncompressed ${curve} point, starting with 0x04`;\n};\n/** @internal */\nexport const checkNamedCurve = curve => algorithm => {\n const namedCurve = algorithm.namedCurve;\n return namedCurve === curve ? undefined : `Expected a ${curve} key, not ${namedCurve}`;\n};\n/** @internal */\nexport const checkHash = hash => algorithm => {\n const keyHash = algorithm.hash?.name;\n return keyHash === hash ? undefined : `Expected a key for ${hash}, not ${keyHash}`;\n};\n/** @internal */\nexport const rsaGenerateParams = (spec, modulusLength) => ({\n ...spec.importParams,\n modulusLength,\n publicExponent: Uint8Array.of(1, 0, 1)\n});\n/**\n * Synchronously validates and wraps a `CryptoKey`.\n *\n * @internal\n */\nexport const fromCryptoKey = (family, method, algorithm, role, cryptoKey) => {\n const spec = family.specOf(algorithm);\n return KeyModel.fromCryptoKey(family.module, method, role === \"private\" ? family.privateKeyProto : family.publicKeyProto, algorithm, cryptoKey, {\n type: role,\n name: spec.name,\n usages: role === \"private\" ? spec.privateUsages : spec.publicUsages,\n usagePolicy: \"all\",\n check: spec.check\n });\n};\nconst concat = (prefix, bytes) => {\n const out = new Uint8Array(prefix.length + bytes.length);\n out.set(prefix);\n out.set(bytes, prefix.length);\n return out;\n};\n/** @internal */\nexport const importPrivate = (subtle, bytes, spec, extractable) => subtle.importKey(\"pkcs8\", spec.seedPrefix === undefined ? bytes : concat(spec.seedPrefix, bytes), spec.importParams, extractable, spec.privateUsages);\n/** @internal */\nexport const importPublic = (subtle, bytes, spec) => subtle.importKey(spec.publicFormat, bytes, spec.importParams, true, spec.publicUsages);\n/**\n * Exports a private `CryptoKey` to its stored form: the seed for Ed25519 and\n * X25519, PKCS#8 otherwise. A seed export in another PKCS#8 form is one the\n * layer cannot read, so it fails with `Unsupported`.\n */\nconst exportPrivate = async (subtle, cryptoKey, spec) => {\n const pkcs8 = new Uint8Array(await subtle.exportKey(\"pkcs8\", cryptoKey));\n const prefix = spec.seedPrefix;\n if (prefix === undefined) return pkcs8;\n if (pkcs8.length !== prefix.length + seedLength || !prefix.every((byte, i) => pkcs8[i] === byte)) {\n throw new internal.Failure(new CryptoError.Unsupported({\n description: `${spec.name} private key was exported in an unexpected PKCS#8 form`\n }));\n }\n return pkcs8.slice(prefix.length);\n};\nconst exportPublic = async (subtle, cryptoKey, spec) => new Uint8Array(await subtle.exportKey(spec.publicFormat, cryptoKey));\n/** @internal */\nexport const exportKey = (subtle, cryptoKey, spec, role) => role === \"private\" ? exportPrivate(subtle, cryptoKey, spec) : exportPublic(subtle, cryptoKey, spec);\n/**\n * Exports a key's stored representation as fresh bytes, reading the\n * `WebCrypto` reference for `CryptoKey`-backed keys.\n *\n * @internal\n */\nexport const toBytes = (family, key) => KeyModel.toBytes(family.module, key, (subtle, cryptoKey) => exportKey(subtle, cryptoKey, family.specOf(key.algorithm), family.isPrivateKey(key) ? \"private\" : \"public\"));\n/**\n * Per-layer caches for imported byte-backed keys.\n *\n * @internal\n */\nexport const makeCaches = family => ({\n privateKey: KeyModel.makeCache((subtle, bytes, algorithm) => importPrivate(subtle, bytes, family.specOf(algorithm), false)),\n publicKey: KeyModel.makeCache((subtle, bytes, algorithm) => importPublic(subtle, bytes, family.specOf(algorithm)))\n});\n/**\n * Computes the stored public key of an extractable private `CryptoKey`.\n *\n * WebCrypto cannot derive a public key directly, but a private key's JWK\n * export carries the public members, which import as a public key.\n */\nconst publicOf = async (subtle, privateKey, spec) => {\n const {\n d,\n p,\n q,\n dp,\n dq,\n qi,\n oth,\n key_ops,\n ext,\n alg,\n ...jwk\n } = await subtle.exportKey(\"jwk\", privateKey);\n const publicKey = await subtle.importKey(\"jwk\", jwk, spec.importParams, true, spec.publicUsages);\n return exportPublic(subtle, publicKey, spec);\n};\n/**\n * Generates a key pair in its stored forms. Ed25519 and X25519 private keys\n * are 32 bytes from `SecureRandom`, so a seeded `SecureRandom` reproduces\n * them. EC and RSA keys come from WebCrypto's own randomness.\n *\n * @internal\n */\nexport const generateKeyPair = (family, crypto, random, algorithm, params) => {\n const spec = family.specOf(algorithm);\n const generate = async (subtle, seed) => {\n if (seed !== undefined) {\n const privateKey = await importPrivate(subtle, seed, spec, true);\n return {\n privateKey: seed,\n publicKey: await publicOf(subtle, privateKey, spec)\n };\n }\n const usages = [...new Set([...spec.privateUsages, ...spec.publicUsages])];\n const pair = await subtle.generateKey(params, true, usages);\n return {\n privateKey: await exportPrivate(subtle, pair.privateKey, spec),\n publicKey: await exportPublic(subtle, pair.publicKey, spec)\n };\n };\n return Effect.flatMap(spec.seedPrefix === undefined ? Effect.undefined : random.randomBytes(seedLength), seed => Effect.map(internal.run(family.module, \"generateKeyPair\", algorithm.name, crypto, subtle => generate(subtle, seed)), ({\n privateKey,\n publicKey\n }) => ({\n privateKey: KeyModel.makeBytes(family.privateKeyProto, algorithm, privateKey),\n publicKey: KeyModel.makeBytes(family.publicKeyProto, algorithm, publicKey)\n })));\n};\n/**\n * Computes the public key of a private key, failing with `NotExtractable`\n * for a non-extractable `CryptoKey`, whose public members cannot be read.\n *\n * @internal\n */\nexport const publicKeyOf = (family, crypto, privateKey) => Effect.suspend(() => {\n const stored = KeyModel.material(privateKey);\n if (stored._tag === \"CryptoKey\" && !stored.cryptoKey.extractable) {\n return internal.notExtractable(family.module, \"publicKeyOf\");\n }\n const spec = family.specOf(privateKey.algorithm);\n return Effect.map(internal.run(family.module, \"publicKeyOf\", privateKey.algorithm.name, crypto, async subtle => publicOf(subtle, stored._tag === \"CryptoKey\" ? stored.cryptoKey : await importPrivate(subtle, stored.bytes, spec, true), spec)), bytes => KeyModel.makeBytes(family.publicKeyProto, privateKey.algorithm, bytes));\n});\n/**\n * Deno imports raw EC points that are not on the curve and rejects them with\n * a `TypeError` when the key is used. For a byte-backed public key only the\n * key can cause that, so it is `InvalidKey`. Any other `TypeError`, such as a\n * `CryptoKey` from another `Crypto` object, stays a defect.\n *\n * @internal\n */\nexport const publicKeyError = (module, method, publicKey, cause) => KeyModel.material(publicKey)._tag === \"Bytes\" && Predicate.hasProperty(cause, \"name\") && cause.name === \"TypeError\" ? new CryptoError.CryptoError({\n module,\n method,\n reason: new CryptoError.InvalidKey({\n description: \"Invalid public key\",\n cause\n })\n}) : internal.webCryptoError(module, method, publicKey.algorithm.name, cause);\n//# sourceMappingURL=asymmetric.js.map",
|
|
18
|
+
"/**\n * Key agreement: X25519, and ECDH on P-256, P-384 and P-521.\n *\n * The {@link KeyAgreement} service generates key pairs, derives a shared\n * secret from a private key and a peer's public key, and computes a private\n * key's public key. The top-level {@link privateKey}, {@link publicKey},\n * {@link privateKeyFromCryptoKey}, {@link publicKeyFromCryptoKey}, and\n * {@link toBytes} functions build and export keys without a service.\n *\n * Keys carry their algorithm in their type, so deriving a secret from keys on\n * different curves is a type error. The shared secret is plain bytes: pass it\n * through `Kdf` before using it as a key.\n *\n * Keys are opaque. They hold either bytes or a `CryptoKey`, display only their\n * algorithm, and compare by reference. The bytes are:\n *\n * - X25519: the 32-byte private key and the 32-byte public key;\n * - ECDH: PKCS#8 for private keys, and the uncompressed SEC1 point for public\n * keys.\n *\n * Only X25519 private keys and X25519 and ECDH public keys have a raw\n * constructor. ECDH private keys come from\n * `KeyAgreement.generateKeyPair`, `CryptoKey`s, or key formats.\n *\n * **Gotchas**\n *\n * - X25519 needs Chrome 133, Firefox 130, or Safari 17. There is no fallback\n * for older browsers.\n * - X25519 private keys are generated from `SecureRandom` bytes, so a seeded\n * `SecureRandom` reproduces them. ECDH key generation uses WebCrypto's own\n * randomness and cannot be seeded.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as Asymmetric from \"./internal/asymmetric.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst PrivateKeyTypeId = \"~effect/crypto/KeyAgreement/PrivateKey\";\nconst PublicKeyTypeId = \"~effect/crypto/KeyAgreement/PublicKey\";\n/**\n * X25519 (RFC 7748).\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const x25519 = {\n _tag: \"X25519\",\n name: \"x25519\"\n};\n/**\n * ECDH on P-256, with 32-byte shared secrets.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdhP256 = {\n _tag: \"Ecdh\",\n name: \"ecdhP256\",\n namedCurve: \"P-256\"\n};\n/**\n * ECDH on P-384, with 48-byte shared secrets.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdhP384 = {\n _tag: \"Ecdh\",\n name: \"ecdhP384\",\n namedCurve: \"P-384\"\n};\n/**\n * ECDH on P-521, with 66-byte shared secrets.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdhP521 = {\n _tag: \"Ecdh\",\n name: \"ecdhP521\",\n namedCurve: \"P-521\"\n};\nconst PrivateKeyProto = /*#__PURE__*/KeyModel.redactedProto(PrivateKeyTypeId, \"KeyAgreement.PrivateKey\");\nconst PublicKeyProto = /*#__PURE__*/KeyModel.redactedProto(PublicKeyTypeId, \"KeyAgreement.PublicKey\");\n/**\n * Checks whether a value is a {@link PrivateKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPrivateKey = u => Predicate.hasProperty(u, PrivateKeyTypeId);\n/**\n * Checks whether a value is a {@link PublicKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPublicKey = u => Predicate.hasProperty(u, PublicKeyTypeId);\nconst specOf = algorithm => algorithm._tag === \"X25519\" ? {\n name: \"X25519\",\n importParams: {\n name: \"X25519\"\n },\n privateUsages: [\"deriveBits\"],\n publicUsages: [],\n seedPrefix: Asymmetric.x25519Prefix,\n publicFormat: \"raw\"\n} : {\n name: \"ECDH\",\n importParams: {\n name: \"ECDH\",\n namedCurve: algorithm.namedCurve\n },\n privateUsages: [\"deriveBits\"],\n publicUsages: [],\n seedPrefix: undefined,\n publicFormat: \"raw\",\n check: Asymmetric.checkNamedCurve(algorithm.namedCurve)\n};\n/** @internal */\nexport const family = {\n module: \"KeyAgreement\",\n specOf,\n privateKeyProto: PrivateKeyProto,\n publicKeyProto: PublicKeyProto,\n isPrivateKey\n};\n// P-521 coordinates are 521 bits, padded to 66 bytes.\nconst sharedSecretBits = algorithm => algorithm._tag === \"X25519\" ? 256 : 8 * Asymmetric.coordinateSizes[algorithm.namedCurve];\nconst invalidPeer = (description, cause) => new CryptoError.CryptoError({\n module: \"KeyAgreement\",\n method: \"deriveSharedSecret\",\n reason: new CryptoError.InvalidKey(cause === undefined ? {\n description\n } : {\n description,\n cause\n })\n});\n/**\n * Service that generates key pairs, derives shared secrets, and computes\n * public keys.\n *\n * **Example** (Agreeing on a secret with X25519)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { KeyAgreement, SecureRandom } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const keyAgreement = yield* KeyAgreement.KeyAgreement\n * const alice = yield* keyAgreement.generateKeyPair(KeyAgreement.x25519)\n * const bob = yield* keyAgreement.generateKeyPair(KeyAgreement.x25519)\n * const aliceSecret = yield* keyAgreement.deriveSharedSecret(alice.privateKey, bob.publicKey)\n * const bobSecret = yield* keyAgreement.deriveSharedSecret(bob.privateKey, alice.publicKey)\n * return aliceSecret.every((byte, i) => byte === bobSecret[i])\n * })\n *\n * const layer = KeyAgreement.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))\n * await Effect.runPromise(program.pipe(Effect.provide(layer))) // => true\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class KeyAgreement extends /*#__PURE__*/Context.Service()(\"effect/crypto/KeyAgreement\") {}\n/**\n * Layer that provides `KeyAgreement` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * Every algorithm runs on `crypto.subtle`. The layer imports a byte-backed\n * key on first use and caches the `CryptoKey`. X25519 private keys come from\n * `SecureRandom`, so a seeded `SecureRandom` reproduces them.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(KeyAgreement, /*#__PURE__*/Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const caches = Asymmetric.makeCaches(family);\n return KeyAgreement.of({\n generateKeyPair: algorithm => Asymmetric.generateKeyPair(family, crypto, random, algorithm, specOf(algorithm).importParams),\n deriveSharedSecret: (privateKey, publicKey) => Effect.suspend(() => {\n const algorithm = privateKey.algorithm;\n // The types keep curves apart, but keys typed with the default\n // `Algorithm` can still differ at run time.\n if (algorithm.name !== publicKey.algorithm.name) {\n return Effect.fail(invalidPeer(`Expected a ${algorithm.name} public key, not ${publicKey.algorithm.name}`));\n }\n const onError = cause => Asymmetric.publicKeyError(\"KeyAgreement\", \"deriveSharedSecret\", publicKey, cause);\n // The keys are imported before deriving, so an `OperationError` from\n // `deriveBits` can only come from the peer key.\n return internal.run(\"KeyAgreement\", \"deriveSharedSecret\", algorithm.name, crypto, async subtle => ({\n privateKey: await caches.privateKey(subtle, privateKey),\n publicKey: await caches.publicKey(subtle, publicKey)\n }), onError).pipe(Effect.flatMap(keys => internal.run(\"KeyAgreement\", \"deriveSharedSecret\", algorithm.name, crypto, async subtle => new Uint8Array(await subtle.deriveBits({\n name: specOf(algorithm).name,\n public: keys.publicKey\n }, keys.privateKey, sharedSecretBits(algorithm))), cause => internal.isOperationError(cause) ? invalidPeer(\"Invalid peer public key\", cause) : onError(cause))), Effect.flatMap(secret =>\n // RFC 7748, section 6.1: an all-zero X25519 output means the peer\n // sent a low-order point, and protocols such as SSH must abort.\n algorithm._tag === \"X25519\" && secret.every(byte => byte === 0) ? Effect.fail(invalidPeer(\"X25519 shared secret must not be all zeros\")) : Effect.succeed(secret)));\n }),\n publicKeyOf: privateKey => Asymmetric.publicKeyOf(family, crypto, privateKey)\n });\n}));\n/**\n * Builds an X25519 private key from its 32 bytes.\n *\n * **Details**\n *\n * The bytes are copied. Another length fails with an `InvalidKey` reason,\n * including the 64-byte `private key‖public key` form libsodium uses: pass\n * its first 32 bytes. ECDH private keys have no raw form, so passing them is\n * a type error.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const privateKey = (algorithm, bytes) => KeyModel.fromBytes(\"KeyAgreement\", \"privateKey\", PrivateKeyProto, algorithm, bytes, Asymmetric.checkSeedLength(\"X25519\", \"private\"));\n/**\n * Builds a public key from its raw form: 32 bytes for X25519, or an\n * uncompressed SEC1 point for ECDH.\n *\n * **Details**\n *\n * The bytes are copied. A wrong length, or a compressed point, fails with an\n * `InvalidKey` reason. Only uncompressed points are taken because Safari and\n * Firefox before 146 reject compressed ones in raw import, though they accept\n * them inside SPKI: decode a compressed point with `KeyFormat.spki`. Whether a\n * point is on the curve is checked when the key is first used.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const publicKey = (algorithm, bytes) => KeyModel.fromBytes(\"KeyAgreement\", \"publicKey\", PublicKeyProto, algorithm, bytes, algorithm._tag === \"Ecdh\" ? Asymmetric.checkPoint(algorithm.namedCurve) : Asymmetric.checkSeedLength(\"X25519\", \"public\"));\n/**\n * Builds a private key from an existing `CryptoKey`, such as a\n * non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a private key of the algorithm's WebCrypto name and\n * curve, with the `deriveBits` usage. Otherwise the constructor fails with an\n * `InvalidKey` reason. The key must come from the `Crypto` object of the\n * `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const privateKeyFromCryptoKey = (algorithm, cryptoKey) => Asymmetric.fromCryptoKey(family, \"privateKeyFromCryptoKey\", algorithm, \"private\", cryptoKey);\n/**\n * Builds a public key from an existing `CryptoKey`.\n *\n * **Details**\n *\n * The `CryptoKey` must be a public key of the algorithm's WebCrypto name and\n * curve. Public keys need no usages. Otherwise the constructor fails with an\n * `InvalidKey` reason. The key must come from the `Crypto` object of the\n * `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const publicKeyFromCryptoKey = (algorithm, cryptoKey) => Asymmetric.fromCryptoKey(family, \"publicKeyFromCryptoKey\", algorithm, \"public\", cryptoKey);\n/**\n * Exports a key's stored bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array`: the raw key for X25519, and PKCS#8 or the\n * uncompressed point for ECDH. A `CryptoKey`-backed key is exported on the\n * `WebCrypto` reference, and fails with a `NotExtractable` reason when the\n * `CryptoKey` is not extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => Asymmetric.toBytes(family, key);\n//# sourceMappingURL=KeyAgreement.js.map",
|
|
19
|
+
"/**\n * Message digests: MD5, SHA-1, SHA-256, SHA-384, and SHA-512.\n *\n * The {@link Digest} service computes digests and lowercase hex strings.\n * Provide {@link layerWebCrypto} to run it on the `WebCrypto` reference,\n * or mock the service with `Layer.mock`.\n *\n * MD5 runs a pure TypeScript implementation vendored from `@noble/hashes`\n * 2.4.0, because WebCrypto does not provide it. Whether the `@noble/hashes`\n * audit covers its MD5 code has not been confirmed. The SHA algorithms run on\n * `crypto.subtle`.\n *\n * Output is stable byte for byte, so digests can be persisted.\n *\n * **Gotchas**\n *\n * MD5 and SHA-1 are broken for collision resistance. Use them only for\n * interoperability with existing protocols and checksums.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Hex from \"../encoding/Hex.js\";\nimport * as Layer from \"../Layer.js\";\nimport { webCryptoDigest } from \"./internal/digest.js\";\nimport * as Md5 from \"./internal/md5.js\";\nimport { WebCrypto } from \"./WebCrypto.js\";\n/**\n * MD5 (RFC 1321), with a 16-byte output.\n *\n * **Gotchas**\n *\n * MD5 is broken for collision resistance. Use it only for interoperability\n * with existing protocols and checksums.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const md5 = {\n name: \"MD5\",\n outputLength: 16,\n implementation: Md5.md5\n};\n/**\n * SHA-1, with a 20-byte output.\n *\n * **Gotchas**\n *\n * SHA-1 is broken for collision resistance. Use it only for interoperability\n * with existing protocols.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const sha1 = {\n name: \"SHA-1\",\n outputLength: 20,\n implementation: undefined\n};\n/**\n * SHA-256, with a 32-byte output.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const sha256 = {\n name: \"SHA-256\",\n outputLength: 32,\n implementation: undefined\n};\n/**\n * SHA-384, with a 48-byte output.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const sha384 = {\n name: \"SHA-384\",\n outputLength: 48,\n implementation: undefined\n};\n/**\n * SHA-512, with a 64-byte output.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const sha512 = {\n name: \"SHA-512\",\n outputLength: 64,\n implementation: undefined\n};\n/**\n * Converts a hash name to an algorithm-name suffix: `\"SHA-256\"` to `\"Sha256\"`.\n *\n * @internal\n */\nexport const nameSuffix = hash => hash.name.charAt(0) + hash.name.slice(1).toLowerCase().replace(\"-\", \"\");\n/**\n * Service that computes message digests.\n *\n * **Example** (Hashing with SHA-256)\n *\n * ```ts import.meta.vitest\n * import { Effect } from \"effect\"\n * import { Digest } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const digest = yield* Digest.Digest\n * return yield* digest.digestHex(Digest.sha256, new TextEncoder().encode(\"abc\"))\n * })\n *\n * const hex = await Effect.runPromise(program.pipe(Effect.provide(Digest.layerWebCrypto)))\n * hex.length // => 64\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Digest extends /*#__PURE__*/Context.Service()(\"effect/crypto/Digest\") {}\n/**\n * Layer that provides `Digest` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * The SHA algorithms run on `crypto.subtle`, and MD5 on the pure TypeScript\n * implementation. Without `crypto.subtle`, the layer still builds and MD5\n * keeps working, but SHA digests die.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(Digest, /*#__PURE__*/WebCrypto.use(crypto => Effect.succeed({\n digest: (algorithm, data) => webCryptoDigest(crypto, algorithm, data),\n digestHex: (algorithm, data) => Effect.map(webCryptoDigest(crypto, algorithm, data), Hex.encode)\n})));\n//# sourceMappingURL=Digest.js.map",
|
|
20
|
+
"/**\n * Message authentication codes: HMAC with SHA-1, SHA-256, SHA-384, or\n * SHA-512.\n *\n * The {@link Mac} service generates keys, signs data, and verifies tags. The\n * top-level {@link key}, {@link fromCryptoKey}, and {@link toBytes} functions\n * build and export keys without a service, and {@link timingSafeEqual}\n * compares byte arrays in constant time.\n *\n * Keys are opaque. They hold either key bytes or a `CryptoKey`, display only\n * their algorithm, and compare by reference.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as Digest from \"./Digest.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst TypeId = \"~effect/crypto/Mac/Key\";\n/**\n * HMAC with SHA-1, with a 20-byte tag.\n *\n * **Gotchas**\n *\n * HMAC-SHA-1 is still secure as a MAC, but use it only for interoperability\n * with existing protocols.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hmacSha1 = {\n name: \"hmacSha1\",\n hash: Digest.sha1\n};\n/**\n * HMAC with SHA-256, with a 32-byte tag.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hmacSha256 = {\n name: \"hmacSha256\",\n hash: Digest.sha256\n};\n/**\n * HMAC with SHA-384, with a 48-byte tag.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hmacSha384 = {\n name: \"hmacSha384\",\n hash: Digest.sha384\n};\n/**\n * HMAC with SHA-512, with a 64-byte tag.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hmacSha512 = {\n name: \"hmacSha512\",\n hash: Digest.sha512\n};\nconst KeyProto = /*#__PURE__*/KeyModel.redactedProto(TypeId, \"Mac.Key\");\n/**\n * Checks whether a value is a {@link Key}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isKey = u => Predicate.hasProperty(u, TypeId);\n// Generated keys have the hash's block size, as Web Crypto generates them.\nconst blockSizes = {\n \"MD5\": 64,\n \"SHA-1\": 64,\n \"SHA-256\": 64,\n \"SHA-384\": 128,\n \"SHA-512\": 128\n};\n/**\n * Service that generates HMAC keys, signs data, and verifies tags.\n *\n * **Example** (Signing and verifying a message)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { Mac, SecureRandom } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const mac = yield* Mac.Mac\n * const key = yield* mac.generateKey(Mac.hmacSha256)\n * const data = new TextEncoder().encode(\"message\")\n * const tag = yield* mac.sign(key, data)\n * return yield* mac.verify(key, tag, data)\n * })\n *\n * const layer = Mac.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))\n * const valid = await Effect.runPromise(program.pipe(Effect.provide(layer)))\n * valid // => true\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Mac extends /*#__PURE__*/Context.Service()(\"effect/crypto/Mac\") {}\nconst importParams = algorithm => ({\n name: \"HMAC\",\n hash: algorithm.hash.name\n});\n/**\n * Builds a `Mac` layer on the `WebCrypto` reference that can sign and verify\n * byte-backed keys with a synchronous HMAC primitive.\n *\n * **When to use**\n *\n * Use to run HMAC on a runtime's native code, as `NodeCrypto.layerMac` does\n * with `createHmac` from `node:crypto`.\n *\n * **Details**\n *\n * `hmac` receives the hash name, the key bytes, and the data, and returns the\n * tag. It runs only for byte-backed keys. `CryptoKey`-backed keys run on\n * `crypto.subtle`, and generated keys come from `SecureRandom`, as in\n * {@link layerWebCrypto}. `verify` computes the tag with `hmac` and compares\n * it with {@link timingSafeEqual}. Without `hmac`, the layer is\n * {@link layerWebCrypto}.\n *\n * **Gotchas**\n *\n * `hmac` receives the key's own bytes, not a copy, so it must not modify or\n * keep them.\n *\n * **Example** (Signing with a native HMAC)\n *\n * ```ts\n * import { Layer } from \"effect\"\n * import { Mac, SecureRandom } from \"effect/crypto\"\n *\n * declare const nativeHmac: (hash: string, key: Uint8Array, data: Uint8Array) => Uint8Array\n *\n * const layer = Mac.layerWebCryptoWith({ hmac: nativeHmac }).pipe(\n * Layer.provide(SecureRandom.layerWebCrypto)\n * )\n * ```\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCryptoWith = options => Layer.effect(Mac, Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const cryptoKeyFor = KeyModel.makeCache((subtle, bytes, algorithm) => subtle.importKey(\"raw\", bytes, importParams(algorithm), false, [\"sign\", \"verify\"]));\n const hmac = options.hmac;\n // Computes a byte-backed key's tags with `hmac`, or `undefined` to use WebCrypto.\n const hmacTag = key => {\n if (hmac === undefined) return undefined;\n const stored = KeyModel.material(key);\n return stored._tag === \"Bytes\" ? data => hmac(key.algorithm.hash.name, stored.bytes, data) : undefined;\n };\n return Mac.of({\n generateKey: algorithm => Effect.map(random.randomBytes(blockSizes[algorithm.hash.name]), bytes => KeyModel.makeBytes(KeyProto, algorithm, bytes)),\n sign: (key, data) => {\n const tagOf = hmacTag(key);\n return tagOf !== undefined ? Effect.sync(() => tagOf(data)) : internal.run(\"Mac\", \"sign\", key.algorithm.name, crypto, async subtle => new Uint8Array(await subtle.sign(\"HMAC\", await cryptoKeyFor(subtle, key), data)));\n },\n // Both paths compare tags in constant time and reject other lengths.\n verify: (key, tag, data) => {\n const tagOf = hmacTag(key);\n return tagOf !== undefined ? Effect.sync(() => timingSafeEqual(tagOf(data), tag)) : internal.run(\"Mac\", \"verify\", key.algorithm.name, crypto, async subtle => subtle.verify(\"HMAC\", await cryptoKeyFor(subtle, key), tag, data));\n }\n });\n}));\n/**\n * Layer that provides `Mac` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * Signing and verification run on `crypto.subtle`. The layer imports a\n * byte-backed key on first use and caches the `CryptoKey`. Generated keys come\n * from `SecureRandom`, so a seeded `SecureRandom` gives reproducible keys.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/layerWebCryptoWith({});\n/**\n * Builds a key from raw key bytes.\n *\n * **Details**\n *\n * The bytes are copied into a new `Uint8Array`, so later changes to the input,\n * including a Node.js `Buffer`, do not reach the key. Any non-empty length is\n * accepted; RFC 2104 recommends at least the hash's output length. An empty key\n * fails with an `InvalidKey` reason.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const key = (algorithm, bytes) => KeyModel.fromBytes(\"Mac\", \"key\", KeyProto, algorithm, bytes, bytes => bytes.length === 0 ? \"An HMAC key cannot be empty\" : undefined);\n/**\n * Builds a key from an existing `CryptoKey`, such as a non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a secret HMAC key with the algorithm's hash and both\n * the `sign` and `verify` usages, since a key reaches both operations.\n * Otherwise the constructor fails with an `InvalidKey` reason. It must come\n * from the `Crypto` object of the `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromCryptoKey = (algorithm, cryptoKey) => KeyModel.fromCryptoKey(\"Mac\", \"fromCryptoKey\", KeyProto, algorithm, cryptoKey, {\n type: \"secret\",\n name: \"HMAC\",\n usages: [\"sign\", \"verify\"],\n usagePolicy: \"all\",\n check: keyAlgorithm => {\n const hash = keyAlgorithm.hash?.name;\n return hash === algorithm.hash.name ? undefined : `Expected an HMAC key for ${algorithm.hash.name}, not ${hash}`;\n }\n});\n/**\n * Exports a key's bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array` that shares no memory with the key. A\n * `CryptoKey`-backed key is exported on the `WebCrypto` reference, and fails\n * with a `NotExtractable` reason when the `CryptoKey` is not extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => KeyModel.toBytes(\"Mac\", key, KeyModel.exportRaw);\n/**\n * Compares two byte arrays in constant time.\n *\n * **When to use**\n *\n * Use to compare secrets of a fixed, known length, such as tags computed\n * outside {@link Mac}. To check an HMAC tag, use `Mac.verify`.\n *\n * **Gotchas**\n *\n * Arrays of different lengths return `false` immediately, revealing their\n * lengths. Equal-length arrays are compared with an XOR-accumulate loop;\n * JavaScript runtimes do not guarantee constant-time execution.\n *\n * **Example** (Comparing fixed-length secrets)\n *\n * ```ts import.meta.vitest\n * import { Mac } from \"effect/crypto\"\n *\n * const expected = new Uint8Array([1, 2, 3])\n * const received = new Uint8Array([1, 2, 3])\n * Mac.timingSafeEqual(expected, received) // => true\n * ```\n *\n * @stability unstable\n * @category utils\n * @since 4.0.0\n */\nexport const timingSafeEqual = (a, b) => {\n if (a.length !== b.length) return false;\n let difference = 0;\n for (let i = 0; i < a.length; i++) difference |= a[i] ^ b[i];\n return difference === 0;\n};\n//# sourceMappingURL=Mac.js.map",
|
|
21
|
+
"/**\n * Key wrapping: AES-KW (RFC 3394) and RSA-OAEP (RFC 8017).\n *\n * The {@link KeyWrap} service generates AES-KW keys and RSA-OAEP key pairs,\n * wraps keys, and unwraps them. The top-level {@link key},\n * {@link fromCryptoKey}, {@link privateKeyFromCryptoKey},\n * {@link publicKeyFromCryptoKey}, and {@link toBytes} functions build and\n * export keys without a service.\n *\n * `wrap` takes an `Aead`, `Cipher`, `Mac`, or `KeyWrap` key, never raw bytes,\n * which keeps RSA-OAEP limited to key transport. `unwrap` returns a typed key\n * of the algorithm it is given.\n *\n * A key-encryption key is the key most worth keeping non-extractable, so in\n * browsers {@link fromCryptoKey} is the main way to build one.\n *\n * Keys are opaque. They hold either bytes or a `CryptoKey`, display only their\n * algorithm, and compare by reference. The bytes are the AES-KW key, and\n * PKCS#8 or SPKI DER for RSA-OAEP.\n *\n * **Gotchas**\n *\n * - AES-KW wraps keys whose length is a multiple of 8 bytes and at least 16\n * bytes. Other lengths fail with an `InvalidArgument` reason.\n * - RSA-OAEP key generation and encryption use WebCrypto's own randomness and\n * cannot be seeded through `SecureRandom`.\n * - Safari rejects RSA-OAEP keys over 4096 bits.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as Aead from \"./Aead.js\";\nimport * as Cipher from \"./Cipher.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as Digest from \"./Digest.js\";\nimport * as Asymmetric from \"./internal/asymmetric.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as Mac from \"./Mac.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst KeyTypeId = \"~effect/crypto/KeyWrap/Key\";\nconst PrivateKeyTypeId = \"~effect/crypto/KeyWrap/PrivateKey\";\nconst PublicKeyTypeId = \"~effect/crypto/KeyWrap/PublicKey\";\n/**\n * AES-128-KW (JOSE A128KW), with a 16-byte key.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes128Kw = {\n _tag: \"AesKw\",\n name: \"aes128Kw\",\n keyLength: 16\n};\n/**\n * AES-256-KW (JOSE A256KW), with a 32-byte key.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const aes256Kw = {\n _tag: \"AesKw\",\n name: \"aes256Kw\",\n keyLength: 32\n};\n/**\n * Builds an RSA-OAEP algorithm for a hash and a modulus length in bits.\n *\n * **Details**\n *\n * MGF1 uses the same hash. There is no OAEP label.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaOaep = options => ({\n _tag: \"RsaOaep\",\n name: `rsaOaep${Digest.nameSuffix(options.hash)}`,\n hash: options.hash,\n modulusLength: options.modulusLength\n});\n/**\n * RSA-OAEP with SHA-256 (JOSE RSA-OAEP-256), generating 3072-bit keys. This is\n * the default RSA-OAEP algorithm.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaOaepSha256 = /*#__PURE__*/rsaOaep({\n hash: Digest.sha256,\n modulusLength: 3072\n});\n/**\n * RSA-OAEP with SHA-1 (JOSE RSA-OAEP), generating 3072-bit keys.\n *\n * **When to use**\n *\n * Use to interoperate with JOSE `RSA-OAEP`. Otherwise prefer\n * {@link rsaOaepSha256}.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaOaepSha1 = /*#__PURE__*/rsaOaep({\n hash: Digest.sha1,\n modulusLength: 3072\n});\nconst KeyProto = /*#__PURE__*/KeyModel.redactedProto(KeyTypeId, \"KeyWrap.Key\");\nconst PrivateKeyProto = /*#__PURE__*/KeyModel.redactedProto(PrivateKeyTypeId, \"KeyWrap.PrivateKey\");\nconst PublicKeyProto = /*#__PURE__*/KeyModel.redactedProto(PublicKeyTypeId, \"KeyWrap.PublicKey\");\n/**\n * Checks whether a value is an AES-KW {@link Key}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isKey = u => Predicate.hasProperty(u, KeyTypeId);\n/**\n * Checks whether a value is an RSA-OAEP {@link PrivateKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPrivateKey = u => Predicate.hasProperty(u, PrivateKeyTypeId);\n/**\n * Checks whether a value is an RSA-OAEP {@link PublicKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPublicKey = u => Predicate.hasProperty(u, PublicKeyTypeId);\nconst specOf = algorithm => ({\n name: \"RSA-OAEP\",\n importParams: {\n name: \"RSA-OAEP\",\n hash: algorithm.hash.name\n },\n privateUsages: [\"decrypt\"],\n publicUsages: [\"encrypt\"],\n seedPrefix: undefined,\n publicFormat: \"spki\",\n check: Asymmetric.checkHash(algorithm.hash.name)\n});\n/** @internal */\nexport const family = {\n module: \"KeyWrap\",\n specOf,\n privateKeyProto: PrivateKeyProto,\n publicKeyProto: PublicKeyProto,\n isPrivateKey\n};\n/** @internal */\nexport const secretFamily = algorithm => \"nonceLength\" in algorithm ? Aead : \"mode\" in algorithm ? Cipher : \"_tag\" in algorithm ? {\n key,\n toBytes\n} : Mac;\n// AES-KW in WebCrypto only wraps `CryptoKey`s, so the key bytes go through a\n// temporary extractable HMAC key, which imports any non-empty length.\nconst hmacParams = {\n name: \"HMAC\",\n hash: \"SHA-256\"\n};\nconst rsaOaepParams = {\n name: \"RSA-OAEP\"\n};\nconst invalidArgument = description => new internal.Failure(new CryptoError.InvalidArgument({\n description\n}));\n// RFC 8017, section 7.1.1: the message fits the modulus minus two hashes and\n// two bytes.\nconst checkOaepLength = (algorithm, cryptoKey, length) => {\n const modulusLength = cryptoKey.algorithm.modulusLength;\n const max = Math.ceil(modulusLength / 8) - 2 * algorithm.hash.outputLength - 2;\n if (length > max) {\n throw invalidArgument(`A ${modulusLength}-bit RSA-OAEP key with ${algorithm.hash.name} wraps at most ${max} bytes, not ${length}`);\n }\n};\n// RFC 3394, section 2: keys are at least two 64-bit blocks, and the wrapped\n// form adds one block.\nconst checkKwLength = (length, overhead) => {\n if (length % 8 !== 0 || length < 16 + overhead) {\n throw invalidArgument(`AES-KW needs a multiple of 8 bytes and at least ${16 + overhead} bytes, not ${length}`);\n }\n};\n/**\n * Service that generates keys, wraps keys, and unwraps them.\n *\n * **Example** (Wrapping an AES-GCM key with AES-KW)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { Aead, KeyWrap, SecureRandom } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const keyWrap = yield* KeyWrap.KeyWrap\n * const kek = yield* keyWrap.generateKey(KeyWrap.aes256Kw)\n * const key = yield* Aead.key(Aead.aes256Gcm, new Uint8Array(32))\n * const wrapped = yield* keyWrap.wrap(kek, key)\n * const unwrapped = yield* keyWrap.unwrap(kek, Aead.aes256Gcm, wrapped)\n * return [wrapped.length, unwrapped.algorithm.name]\n * })\n *\n * const layer = KeyWrap.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))\n * await Effect.runPromise(program.pipe(Effect.provide(layer))) // => [40, \"aes256Gcm\"]\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class KeyWrap extends /*#__PURE__*/Context.Service()(\"effect/crypto/KeyWrap\") {}\n/**\n * Layer that provides `KeyWrap` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * The layer imports a byte-backed key on first use and caches the\n * `CryptoKey`. AES-KW keys come from `SecureRandom`, so a seeded\n * `SecureRandom` reproduces them.\n *\n * WebCrypto's AES-KW only wraps `CryptoKey`s, so the layer imports the target\n * bytes as a temporary extractable HMAC key and wraps that. RSA-OAEP uses\n * `encrypt` and `decrypt` when the key allows them, and otherwise the same\n * route through `wrapKey` and `unwrapKey`. Both give the same ciphertext.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(KeyWrap, /*#__PURE__*/Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const kwCryptoKey = KeyModel.makeCache((subtle, bytes) => subtle.importKey(\"raw\", bytes, \"AES-KW\", false, [\"wrapKey\", \"unwrapKey\"]));\n const caches = Asymmetric.makeCaches(family);\n const wrapBytes = (wrapKey, bytes) => internal.run(\"KeyWrap\", \"wrap\", wrapKey.algorithm.name, crypto, async subtle => {\n if (isKey(wrapKey)) {\n checkKwLength(bytes.length, 0);\n const kek = await kwCryptoKey(subtle, wrapKey);\n const target = await subtle.importKey(\"raw\", bytes, hmacParams, true, [\"sign\"]);\n return new Uint8Array(await subtle.wrapKey(\"raw\", target, kek, \"AES-KW\"));\n }\n const publicKey = await caches.publicKey(subtle, wrapKey);\n checkOaepLength(wrapKey.algorithm, publicKey, bytes.length);\n if (publicKey.usages.includes(\"encrypt\")) {\n return new Uint8Array(await subtle.encrypt(rsaOaepParams, publicKey, bytes));\n }\n const target = await subtle.importKey(\"raw\", bytes, hmacParams, true, [\"sign\"]);\n return new Uint8Array(await subtle.wrapKey(\"raw\", target, publicKey, rsaOaepParams));\n });\n const unwrapBytes = (unwrapKey, wrapped) => internal.run(\"KeyWrap\", \"unwrap\", unwrapKey.algorithm.name, crypto, async subtle => {\n if (isKey(unwrapKey)) {\n checkKwLength(wrapped.length, 8);\n const kek = await kwCryptoKey(subtle, unwrapKey);\n const target = await subtle.unwrapKey(\"raw\", wrapped, kek, \"AES-KW\", hmacParams, true, [\"sign\"]);\n return KeyModel.exportRaw(subtle, target);\n }\n const privateKey = await caches.privateKey(subtle, unwrapKey);\n if (privateKey.usages.includes(\"decrypt\")) {\n return new Uint8Array(await subtle.decrypt(rsaOaepParams, privateKey, wrapped));\n }\n const target = await subtle.unwrapKey(\"raw\", wrapped, privateKey, rsaOaepParams, hmacParams, true, [\"sign\"]);\n return KeyModel.exportRaw(subtle, target);\n }, cause => internal.webCryptoError(\"KeyWrap\", \"unwrap\", unwrapKey.algorithm.name, cause, () => new CryptoError.DecryptionFailed()));\n return KeyWrap.of({\n generateKey: algorithm => Effect.map(random.randomBytes(algorithm.keyLength), bytes => KeyModel.makeBytes(KeyProto, algorithm, bytes)),\n generateKeyPair: algorithm => Asymmetric.generateKeyPair(family, crypto, random, algorithm, Asymmetric.rsaGenerateParams(specOf(algorithm), algorithm.modulusLength)),\n wrap: (wrapKey, key) => Effect.suspend(() => {\n const stored = KeyModel.material(key);\n if (stored._tag === \"CryptoKey\" && !stored.cryptoKey.extractable) {\n return internal.notExtractable(\"KeyWrap\", \"wrap\");\n }\n return secretFamily(key.algorithm).toBytes(key).pipe(Effect.catch(internal.rehome(\"KeyWrap\", \"wrap\")), Effect.flatMap(bytes => wrapBytes(wrapKey, bytes)));\n }),\n unwrap: (unwrapKey, algorithm, wrapped) => Effect.flatMap(unwrapBytes(unwrapKey, wrapped), bytes => secretFamily(algorithm).key(algorithm, bytes).pipe(Effect.catch(internal.rehome(\"KeyWrap\", \"unwrap\"))))\n });\n}));\n/**\n * Builds an AES-KW key from its bytes.\n *\n * **Details**\n *\n * The bytes are copied. A length other than the algorithm's key length fails\n * with an `InvalidKey` reason. RSA-OAEP keys have no raw form, so passing\n * them is a type error.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const key = (algorithm, bytes) => KeyModel.fromBytes(\"KeyWrap\", \"key\", KeyProto, algorithm, bytes, KeyModel.checkKeyLength(algorithm));\n/**\n * Builds an AES-KW key from an existing `CryptoKey`, such as a\n * non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a secret AES-KW key of the algorithm's length with\n * both the `wrapKey` and `unwrapKey` usages, since a key reaches both\n * operations. Otherwise the constructor fails with an `InvalidKey` reason. It\n * must come from the `Crypto` object of the `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromCryptoKey = (algorithm, cryptoKey) => KeyModel.fromCryptoKey(\"KeyWrap\", \"fromCryptoKey\", KeyProto, algorithm, cryptoKey, {\n type: \"secret\",\n name: \"AES-KW\",\n usages: [\"wrapKey\", \"unwrapKey\"],\n usagePolicy: \"all\",\n check: KeyModel.checkAesLength(\"AES-KW\", algorithm.keyLength)\n});\n// RSA-OAEP keys need one usage the layer can use for the key's role, since\n// `wrapKey` and `encrypt` produce the same ciphertext.\nconst rsaFromCryptoKey = (method, proto, algorithm, role, cryptoKey) => KeyModel.fromCryptoKey(\"KeyWrap\", method, proto, algorithm, cryptoKey, {\n type: role,\n name: \"RSA-OAEP\",\n usages: role === \"private\" ? [\"decrypt\", \"unwrapKey\"] : [\"encrypt\", \"wrapKey\"],\n usagePolicy: \"any\",\n check: Asymmetric.checkHash(algorithm.hash.name)\n});\n/**\n * Builds an RSA-OAEP private key from an existing `CryptoKey`, such as a\n * non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be an RSA-OAEP private key with the algorithm's hash\n * and the `decrypt` or `unwrapKey` usage. Otherwise the constructor fails\n * with an `InvalidKey` reason. The modulus length is not checked. The key must\n * come from the `Crypto` object of the `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const privateKeyFromCryptoKey = (algorithm, cryptoKey) => rsaFromCryptoKey(\"privateKeyFromCryptoKey\", PrivateKeyProto, algorithm, \"private\", cryptoKey);\n/**\n * Builds an RSA-OAEP public key from an existing `CryptoKey`.\n *\n * **Details**\n *\n * The `CryptoKey` must be an RSA-OAEP public key with the algorithm's hash and\n * the `encrypt` or `wrapKey` usage. Otherwise the constructor fails with an\n * `InvalidKey` reason. The key must come from the `Crypto` object of the\n * `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const publicKeyFromCryptoKey = (algorithm, cryptoKey) => rsaFromCryptoKey(\"publicKeyFromCryptoKey\", PublicKeyProto, algorithm, \"public\", cryptoKey);\n/**\n * Exports a key's stored bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array`: the AES-KW key, or PKCS#8 or SPKI DER for\n * RSA-OAEP. A `CryptoKey`-backed key is exported on the `WebCrypto`\n * reference, and fails with a `NotExtractable` reason when the `CryptoKey` is\n * not extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => isKey(key) ? KeyModel.toBytes(\"KeyWrap\", key, KeyModel.exportRaw) : Asymmetric.toBytes(family, key);\n//# sourceMappingURL=KeyWrap.js.map",
|
|
22
|
+
"/**\n * Digital signatures: Ed25519, ECDSA on P-256, P-384 and P-521, RSA-PSS, and\n * RSASSA-PKCS1-v1_5.\n *\n * The {@link Signature} service generates key pairs, signs, verifies, and\n * computes a private key's public key. The top-level {@link privateKey},\n * {@link publicKey}, {@link privateKeyFromCryptoKey},\n * {@link publicKeyFromCryptoKey}, and {@link toBytes} functions build and\n * export keys without a service.\n *\n * The hash is part of the algorithm. ECDSA P-256, P-384 and P-521 sign with\n * SHA-256, SHA-384 and SHA-512, as JOSE ES256, ES384 and ES512 do. RSA\n * algorithms come from {@link rsaPss} and {@link rsaPkcs1v15}, with pre-made\n * values such as {@link rsaPssSha256}.\n *\n * Keys are opaque. They hold either bytes or a `CryptoKey`, display only their\n * algorithm, and compare by reference. The bytes are:\n *\n * - Ed25519: the 32-byte seed and the 32-byte public key;\n * - ECDSA: PKCS#8 for private keys, and the uncompressed SEC1 point for public\n * keys;\n * - RSA: PKCS#8 and SPKI DER.\n *\n * Only Ed25519 private keys and Ed25519 and ECDSA public keys have a raw\n * constructor. Other keys come from `Signature.generateKeyPair`,\n * `CryptoKey`s, or key formats.\n *\n * **Gotchas**\n *\n * - Ed25519 needs Chrome 137, Firefox 129, or Safari 17. There is no\n * fallback for older browsers.\n * - Ed25519 keys are generated from `SecureRandom` bytes, so a seeded\n * `SecureRandom` reproduces them. ECDSA and RSA key generation, and ECDSA\n * and RSA-PSS signatures, use WebCrypto's own randomness and cannot be\n * seeded. Test them with round trips such as `verify(sign(data))`.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as Digest from \"./Digest.js\";\nimport * as Asymmetric from \"./internal/asymmetric.js\";\nimport * as KeyModel from \"./internal/key.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport * as SecureRandom from \"./SecureRandom.js\";\nimport * as WebCrypto from \"./WebCrypto.js\";\nconst PrivateKeyTypeId = \"~effect/crypto/Signature/PrivateKey\";\nconst PublicKeyTypeId = \"~effect/crypto/Signature/PublicKey\";\n/**\n * Ed25519 (RFC 8032).\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ed25519 = {\n _tag: \"Ed25519\",\n name: \"ed25519\"\n};\n/**\n * ECDSA on P-256 with SHA-256 (JOSE ES256), with 64-byte signatures.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdsaP256 = {\n _tag: \"Ecdsa\",\n name: \"ecdsaP256\",\n namedCurve: \"P-256\",\n hash: Digest.sha256\n};\n/**\n * ECDSA on P-384 with SHA-384 (JOSE ES384), with 96-byte signatures.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdsaP384 = {\n _tag: \"Ecdsa\",\n name: \"ecdsaP384\",\n namedCurve: \"P-384\",\n hash: Digest.sha384\n};\n/**\n * ECDSA on P-521 with SHA-512 (JOSE ES512), with 132-byte signatures.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const ecdsaP521 = {\n _tag: \"Ecdsa\",\n name: \"ecdsaP521\",\n namedCurve: \"P-521\",\n hash: Digest.sha512\n};\n/**\n * Builds an RSA-PSS algorithm for a hash and a modulus length in bits.\n *\n * **Details**\n *\n * MGF1 uses the same hash. The salt length defaults to the hash's output\n * length.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPss = options => ({\n _tag: \"RsaPss\",\n name: `rsaPss${Digest.nameSuffix(options.hash)}`,\n hash: options.hash,\n modulusLength: options.modulusLength,\n saltLength: options.saltLength ?? options.hash.outputLength\n});\n/**\n * Builds an RSASSA-PKCS1-v1_5 algorithm for a hash and a modulus length in\n * bits.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPkcs1v15 = options => ({\n _tag: \"RsaPkcs1v15\",\n name: `rsaPkcs1v15${Digest.nameSuffix(options.hash)}`,\n hash: options.hash,\n modulusLength: options.modulusLength\n});\n/**\n * RSA-PSS with SHA-256 (JOSE PS256), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPssSha256 = /*#__PURE__*/rsaPss({\n hash: Digest.sha256,\n modulusLength: 3072\n});\n/**\n * RSA-PSS with SHA-384 (JOSE PS384), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPssSha384 = /*#__PURE__*/rsaPss({\n hash: Digest.sha384,\n modulusLength: 3072\n});\n/**\n * RSA-PSS with SHA-512 (JOSE PS512), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPssSha512 = /*#__PURE__*/rsaPss({\n hash: Digest.sha512,\n modulusLength: 3072\n});\n/**\n * RSASSA-PKCS1-v1_5 with SHA-256 (JOSE RS256), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPkcs1v15Sha256 = /*#__PURE__*/rsaPkcs1v15({\n hash: Digest.sha256,\n modulusLength: 3072\n});\n/**\n * RSASSA-PKCS1-v1_5 with SHA-384 (JOSE RS384), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPkcs1v15Sha384 = /*#__PURE__*/rsaPkcs1v15({\n hash: Digest.sha384,\n modulusLength: 3072\n});\n/**\n * RSASSA-PKCS1-v1_5 with SHA-512 (JOSE RS512), generating 3072-bit keys.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const rsaPkcs1v15Sha512 = /*#__PURE__*/rsaPkcs1v15({\n hash: Digest.sha512,\n modulusLength: 3072\n});\nconst PrivateKeyProto = /*#__PURE__*/KeyModel.redactedProto(PrivateKeyTypeId, \"Signature.PrivateKey\");\nconst PublicKeyProto = /*#__PURE__*/KeyModel.redactedProto(PublicKeyTypeId, \"Signature.PublicKey\");\n/**\n * Checks whether a value is a {@link PrivateKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPrivateKey = u => Predicate.hasProperty(u, PrivateKeyTypeId);\n/**\n * Checks whether a value is a {@link PublicKey}.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPublicKey = u => Predicate.hasProperty(u, PublicKeyTypeId);\nconst specOf = algorithm => {\n const base = {\n privateUsages: [\"sign\"],\n publicUsages: [\"verify\"]\n };\n switch (algorithm._tag) {\n case \"Ed25519\":\n return {\n ...base,\n name: \"Ed25519\",\n importParams: {\n name: \"Ed25519\"\n },\n seedPrefix: Asymmetric.ed25519Prefix,\n publicFormat: \"raw\"\n };\n case \"Ecdsa\":\n return {\n ...base,\n name: \"ECDSA\",\n importParams: {\n name: \"ECDSA\",\n namedCurve: algorithm.namedCurve\n },\n seedPrefix: undefined,\n publicFormat: \"raw\",\n check: Asymmetric.checkNamedCurve(algorithm.namedCurve)\n };\n case \"RsaPss\":\n case \"RsaPkcs1v15\":\n {\n const name = algorithm._tag === \"RsaPss\" ? \"RSA-PSS\" : \"RSASSA-PKCS1-v1_5\";\n return {\n ...base,\n name,\n importParams: {\n name,\n hash: algorithm.hash.name\n },\n seedPrefix: undefined,\n publicFormat: \"spki\",\n check: Asymmetric.checkHash(algorithm.hash.name)\n };\n }\n }\n};\n/** @internal */\nexport const family = {\n module: \"Signature\",\n specOf,\n privateKeyProto: PrivateKeyProto,\n publicKeyProto: PublicKeyProto,\n isPrivateKey\n};\nconst signParams = algorithm => {\n switch (algorithm._tag) {\n case \"Ed25519\":\n return {\n name: \"Ed25519\"\n };\n case \"Ecdsa\":\n return {\n name: \"ECDSA\",\n hash: algorithm.hash.name\n };\n case \"RsaPss\":\n return {\n name: \"RSA-PSS\",\n saltLength: algorithm.saltLength\n };\n case \"RsaPkcs1v15\":\n return {\n name: \"RSASSA-PKCS1-v1_5\"\n };\n }\n};\nconst generateParams = algorithm => {\n switch (algorithm._tag) {\n case \"Ed25519\":\n return {\n name: \"Ed25519\"\n };\n case \"Ecdsa\":\n return {\n name: \"ECDSA\",\n namedCurve: algorithm.namedCurve\n };\n case \"RsaPss\":\n case \"RsaPkcs1v15\":\n return Asymmetric.rsaGenerateParams(specOf(algorithm), algorithm.modulusLength);\n }\n};\n// The length of the algorithm's signatures, which for RSA is the size of the\n// key's modulus. A signature of another length is rejected without asking\n// WebCrypto, so every runtime returns `false` for it.\nconst signatureLength = (algorithm, cryptoKey) => {\n switch (algorithm._tag) {\n case \"Ed25519\":\n return 64;\n case \"Ecdsa\":\n return 2 * Asymmetric.coordinateSizes[algorithm.namedCurve];\n case \"RsaPss\":\n case \"RsaPkcs1v15\":\n return Math.ceil(cryptoKey.algorithm.modulusLength / 8);\n }\n};\n// RFC 8017, section 9.1.1: the encoded message must fit the hash, the salt\n// and two more bytes. The modulus is only known once the key is imported, so\n// the check throws inside `run`.\nconst checkSaltLength = (algorithm, cryptoKey) => {\n if (algorithm._tag !== \"RsaPss\") return;\n let problem;\n if (!Number.isSafeInteger(algorithm.saltLength) || algorithm.saltLength < 0) {\n problem = \"PSS salt length must be a non-negative safe integer\";\n } else {\n const modulusLength = cryptoKey.algorithm.modulusLength;\n if (algorithm.hash.outputLength + algorithm.saltLength + 2 > Math.ceil((modulusLength - 1) / 8)) {\n problem = `A ${algorithm.saltLength}-byte PSS salt does not fit a ${modulusLength}-bit key with ${algorithm.hash.name}`;\n }\n }\n if (problem !== undefined) throw new internal.Failure(new CryptoError.InvalidArgument({\n description: problem\n }));\n};\n/**\n * Service that generates key pairs, signs, verifies, and computes public keys.\n *\n * **Example** (Signing and verifying with Ed25519)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer } from \"effect\"\n * import { SecureRandom, Signature } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const signature = yield* Signature.Signature\n * const { privateKey, publicKey } = yield* signature.generateKeyPair(Signature.ed25519)\n * const data = new TextEncoder().encode(\"message\")\n * const signed = yield* signature.sign(privateKey, data)\n * return [signed.length, yield* signature.verify(publicKey, signed, data)]\n * })\n *\n * const layer = Signature.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))\n * await Effect.runPromise(program.pipe(Effect.provide(layer))) // => [64, true]\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Signature extends /*#__PURE__*/Context.Service()(\"effect/crypto/Signature\") {}\n/**\n * Layer that provides `Signature` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * Every algorithm runs on `crypto.subtle`. The layer imports a byte-backed\n * key on first use and caches the `CryptoKey`. Ed25519 private keys come from\n * `SecureRandom`, so a seeded `SecureRandom` reproduces them.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(Signature, /*#__PURE__*/Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const crypto = yield* WebCrypto.WebCrypto;\n const caches = Asymmetric.makeCaches(family);\n return Signature.of({\n generateKeyPair: algorithm => Asymmetric.generateKeyPair(family, crypto, random, algorithm, generateParams(algorithm)),\n sign: (privateKey, data) => internal.run(\"Signature\", \"sign\", privateKey.algorithm.name, crypto, async subtle => {\n const cryptoKey = await caches.privateKey(subtle, privateKey);\n checkSaltLength(privateKey.algorithm, cryptoKey);\n return new Uint8Array(await subtle.sign(signParams(privateKey.algorithm), cryptoKey, data));\n }),\n verify: (publicKey, signature, data) => internal.run(\"Signature\", \"verify\", publicKey.algorithm.name, crypto, async subtle => {\n const cryptoKey = await caches.publicKey(subtle, publicKey);\n checkSaltLength(publicKey.algorithm, cryptoKey);\n if (signature.length !== signatureLength(publicKey.algorithm, cryptoKey)) return false;\n return subtle.verify(signParams(publicKey.algorithm), cryptoKey, signature, data);\n }, cause => Asymmetric.publicKeyError(\"Signature\", \"verify\", publicKey, cause)),\n publicKeyOf: privateKey => Asymmetric.publicKeyOf(family, crypto, privateKey)\n });\n}));\n/**\n * Builds an Ed25519 private key from its 32-byte seed.\n *\n * **Details**\n *\n * The bytes are copied. Another length fails with an `InvalidKey` reason,\n * including the 64-byte `seed‖public key` form libsodium and TweetNaCl use:\n * pass its first 32 bytes. ECDSA and RSA private keys have no raw form, so\n * passing them is a type error.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const privateKey = (algorithm, bytes) => KeyModel.fromBytes(\"Signature\", \"privateKey\", PrivateKeyProto, algorithm, bytes, Asymmetric.checkSeedLength(\"Ed25519\", \"private\"));\n/**\n * Builds a public key from its raw form: 32 bytes for Ed25519, or an\n * uncompressed SEC1 point for ECDSA.\n *\n * **Details**\n *\n * The bytes are copied. A wrong length, or a compressed point, fails with an\n * `InvalidKey` reason. Only uncompressed points are taken because Safari and\n * Firefox before 146 reject compressed ones in raw import, though they accept\n * them inside SPKI: decode a compressed point with `KeyFormat.spki`. Whether a\n * point is on the curve is checked when the key is first used. RSA public keys have\n * no raw form, so passing them is a type error.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const publicKey = (algorithm, bytes) => KeyModel.fromBytes(\"Signature\", \"publicKey\", PublicKeyProto, algorithm, bytes, algorithm._tag === \"Ecdsa\" ? Asymmetric.checkPoint(algorithm.namedCurve) : Asymmetric.checkSeedLength(\"Ed25519\", \"public\"));\n/**\n * Builds a private key from an existing `CryptoKey`, such as a\n * non-extractable one.\n *\n * **Details**\n *\n * The `CryptoKey` must be a private key of the algorithm's WebCrypto name,\n * curve or hash, with the `sign` usage. Otherwise the constructor fails with\n * an `InvalidKey` reason. The modulus length of an RSA algorithm is not\n * checked. The key must come from the `Crypto` object of the `WebCrypto`\n * reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const privateKeyFromCryptoKey = (algorithm, cryptoKey) => Asymmetric.fromCryptoKey(family, \"privateKeyFromCryptoKey\", algorithm, \"private\", cryptoKey);\n/**\n * Builds a public key from an existing `CryptoKey`.\n *\n * **Details**\n *\n * The `CryptoKey` must be a public key of the algorithm's WebCrypto name,\n * curve or hash, with the `verify` usage. Otherwise the constructor fails\n * with an `InvalidKey` reason. The key must come from the `Crypto` object of\n * the `WebCrypto` reference.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const publicKeyFromCryptoKey = (algorithm, cryptoKey) => Asymmetric.fromCryptoKey(family, \"publicKeyFromCryptoKey\", algorithm, \"public\", cryptoKey);\n/**\n * Exports a key's stored bytes.\n *\n * **Details**\n *\n * Returns a fresh `Uint8Array`: the seed or raw public key for Ed25519,\n * PKCS#8 or the uncompressed point for ECDSA, and PKCS#8 or SPKI DER for\n * RSA. A `CryptoKey`-backed key is exported on the `WebCrypto` reference, and\n * fails with a `NotExtractable` reason when the `CryptoKey` is not\n * extractable.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toBytes = key => Asymmetric.toBytes(family, key);\n//# sourceMappingURL=Signature.js.map",
|
|
23
|
+
"/**\n * The `Brand` module adds compile-time names to ordinary TypeScript values so\n * structurally identical values cannot be mixed accidentally. A branded value\n * has the same runtime representation as its unbranded value; the extra\n * information lives in the type system unless you choose a validating\n * constructor.\n *\n * @stability stable\n * @since 2.0.0\n */\nimport * as Arr from \"./Array.js\";\nimport * as Option from \"./Option.js\";\nimport * as Result from \"./Result.js\";\nimport * as SchemaAST from \"./SchemaAST.js\";\nimport * as SchemaIssue from \"./SchemaIssue.js\";\nconst TypeId = \"~effect/Brand\";\n/**\n * Error returned when a branded type is constructed from an invalid value.\n *\n * **Details**\n *\n * The error wraps a `SchemaIssue.Issue`, renders `message` with the default\n * schema issue formatter, and formats as `BrandError(<message>)`.\n *\n * **Gotchas**\n *\n * `BrandError` is an error-like model with `_tag`, `name`, `message`, and\n * `toString`; it does not extend JavaScript `Error`.\n *\n * @stability stable\n * @category errors\n * @since 4.0.0\n */\nexport class BrandError {\n constructor(issue) {\n this.issue = issue;\n }\n /**\n * Discriminant used to identify brand construction failures.\n *\n * @since 4.0.0\n */\n _tag = \"BrandError\";\n /**\n * Error name used by tools that inspect JavaScript error-like objects.\n *\n * @since 4.0.0\n */\n name = \"BrandError\";\n /**\n * Schema issue describing why brand validation failed.\n *\n * @since 4.0.0\n */\n issue;\n /**\n * Human-readable rendering of the validation issue.\n *\n * @since 4.0.0\n */\n get message() {\n return SchemaIssue.defaultFormatter(this.issue);\n }\n /**\n * Formats the brand error together with its validation message.\n *\n * @since 4.0.0\n */\n toString() {\n return `BrandError(${this.message})`;\n }\n}\n/**\n * Returns a `Constructor` that **does not apply any runtime checks** and just\n * returns the provided value.\n *\n * **When to use**\n *\n * Use to create nominal types that allow distinguishing between two values\n * of the same type but with different meanings.\n *\n * @see {@link make} for constructing branded values with validation.\n * @see {@link check} for constructing branded values from schema checks.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport function nominal() {\n return Object.assign(input => input, {\n option: input => Option.some(input),\n result: input => Result.succeed(input),\n is: _ => true\n });\n}\n/**\n * Returns a `Constructor` that can construct a branded type from an unbranded\n * value using the provided `filter` predicate as validation of the input data.\n *\n * **When to use**\n *\n * Use when you want validation while constructing the branded type.\n *\n * @see {@link nominal} for a brand constructor that performs no validation.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport function make(filter) {\n return check(SchemaAST.makeFilter(filter));\n}\n/**\n * Creates a branded type `Constructor` from one or more schema checks.\n *\n * **When to use**\n *\n * Use when you need a branded type constructor that performs runtime validation\n * via schema checks.\n *\n * **Details**\n *\n * Calling the returned constructor validates the unbranded value and throws on\n * failure. Use the returned `option`, `result`, or `is` methods for\n * non-throwing validation.\n *\n * @see {@link nominal} for a brand constructor without runtime validation\n * @see {@link all} for combining multiple brand constructors\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport function check(...checks) {\n const result = input => {\n return Result.mapError(SchemaAST.runChecks(checks, input), issue => new BrandError(issue));\n };\n return Object.assign(input => Result.getOrThrow(result(input)), {\n option: input => Option.getSuccess(result(input)),\n result,\n is: input => Result.isSuccess(result(input)),\n checks\n });\n}\n/**\n * Combines one or more brand constructors to form a single branded type.\n *\n * **When to use**\n *\n * Use to require an input to satisfy every runtime check collected by the\n * provided brand constructors.\n *\n * **Details**\n *\n * If the provided constructors contain runtime checks, the combined\n * constructor succeeds only when all checks pass. If no runtime checks are\n * present, it behaves as a nominal constructor.\n *\n * @stability stable\n * @category combining\n * @since 2.0.0\n */\nexport function all(...brands) {\n const checks = brands.flatMap(brand => brand.checks ?? []);\n return Arr.isArrayNonEmpty(checks) ? check(...checks) : nominal();\n}\n//# sourceMappingURL=Brand.js.map",
|
|
24
|
+
"import * as Arr from \"../Array.js\";\nimport * as Deferred from \"../Deferred.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Fiber from \"../Fiber.js\";\nimport * as Order from \"../Order.js\";\nimport * as Predicate from \"../Predicate.js\";\n// -----------------------------------------------------------------------------\n// compilation\n// -----------------------------------------------------------------------------\nconst maxExpansions = 10_000;\nconst maxExpandedLength = 2 ** 22;\nconst maxBraceDepth = 64;\n/** @internal */\nexport const compile = (patterns, dot) => {\n const nodes = [];\n const starts = new Set();\n for (const pattern of patterns) {\n for (const expanded of expandBraces(pattern)) {\n const start = nodes.length;\n if (compilePattern(expanded, nodes)) {\n starts.add(start);\n }\n }\n }\n const initial = closure(nodes, starts);\n return {\n nodes,\n initial,\n dot,\n masks: nodes.length <= 32 ? compileMasks(nodes, initial) : undefined\n };\n};\nconst compileMasks = (nodes, initial) => {\n let start = 0;\n for (const state of initial) {\n start |= 1 << state;\n }\n let globstar = 0;\n let end = 0;\n let endFile = 0;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n const bit = 1 << i;\n if (node._tag === \"Globstar\") {\n globstar |= bit;\n } else if (node._tag === \"End\") {\n end |= bit;\n if (!node.directoryOnly) {\n endFile |= bit;\n }\n }\n }\n return {\n initial: start,\n globstar,\n end,\n endFile\n };\n};\n// Reject UNC paths rather than collapsing them into local absolute paths.\nconst isUnc = path => path.startsWith(\"//\") && path[2] !== undefined && path[2] !== \"/\";\n// Appends the pattern's nodes, or appends nothing when it can match no path\nconst compilePattern = (pattern, nodes) => {\n if (pattern === \"\" || isUnc(pattern)) {\n return false;\n }\n const raw = splitSegments(pattern);\n const globstar = raw.indexOf(\"**\");\n if (globstar !== -1 && raw.some((segment, i) => i > globstar && (segment === \".\" || segment === \"..\"))) {\n return false;\n }\n const {\n directory,\n segments\n } = normalize(raw);\n if (segments.length === 0) {\n return false;\n }\n for (const segment of segments) {\n if (segment !== \"**\") {\n nodes.push(compileSegment(Array.from(segment)));\n } else if (nodes[nodes.length - 1] !== globstarNode) {\n nodes.push(globstarNode);\n }\n }\n nodes.push({\n _tag: \"End\",\n directoryOnly: directory\n });\n return true;\n};\nconst globstarNode = {\n _tag: \"Globstar\"\n};\nconst splitSegments = pattern => {\n const segments = [];\n let start = 0;\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === \"\\\\\") {\n i++;\n } else if (pattern[i] === \"/\") {\n segments.push(pattern.slice(start, i));\n start = i + 1;\n }\n }\n segments.push(pattern.slice(start));\n return segments;\n};\nconst drive = /^[A-Za-z]:/;\nconst isDrive = segment => segment.length === 2 && drive.test(segment);\n// the root of an absolute path: `\"\"` or a drive such as `C:/`\nconst isRoot = name => name === \"\" || name.length === 3 && name[2] === \"/\" && drive.test(name);\nconst isAbsolute = path => path.startsWith(\"/\") || path[2] === \"/\" && drive.test(path);\n// Preserve absolute roots and a lone `.`; trailing `/` or `/.` marks a directory.\nconst normalize = raw => {\n const segments = [];\n let i = 0;\n if (raw.length > 1 && (raw[0] === \"\" || isDrive(raw[0]))) {\n segments.push(raw[0] === \"\" ? \"\" : `${raw[0]}/`);\n i = 1;\n }\n let directory = false;\n for (; i < raw.length; i++) {\n const segment = raw[i];\n if (segment === \"\" || segment === \".\") {\n directory = i === raw.length - 1 && segments.length > 0;\n } else {\n segments.push(segment);\n directory = false;\n }\n }\n if (segments.length === 0 && raw.includes(\".\")) {\n segments.push(\".\");\n }\n return {\n segments,\n directory\n };\n};\nconst compileSegment = chars => {\n const tokens = [];\n let literal = \"\";\n let magic = false;\n // once a class fails to close, every later `[` in the segment is literal\n let classes = true;\n for (let i = 0; i < chars.length; i++) {\n const char = chars[i];\n if (char === \"\\\\\" && i + 1 < chars.length) {\n literal += chars[++i];\n tokens.push({\n _tag: \"Char\",\n code: chars[i].codePointAt(0)\n });\n } else if (char === \"*\") {\n magic = true;\n if (tokens[tokens.length - 1]?._tag !== \"Star\") {\n tokens.push({\n _tag: \"Star\"\n });\n }\n } else if (char === \"?\") {\n magic = true;\n tokens.push({\n _tag: \"Any\"\n });\n } else if (char === \"[\" && classes) {\n const parsed = parseClass(chars, i);\n if (parsed === undefined) {\n classes = false;\n literal += char;\n tokens.push({\n _tag: \"Char\",\n code: char.codePointAt(0)\n });\n } else {\n magic = true;\n tokens.push(parsed.token);\n i = parsed.end;\n }\n } else {\n literal += char;\n tokens.push({\n _tag: \"Char\",\n code: char.codePointAt(0)\n });\n }\n }\n if (!magic) {\n return {\n _tag: \"Literal\",\n value: literal\n };\n }\n const first = tokens[0];\n return {\n _tag: \"Wildcard\",\n tokens,\n leadingDot: first._tag === \"Char\" && first.code === 0x2e,\n affixes: compileAffixes(tokens)\n };\n};\n// Lone surrogates stay on the token path: `startsWith` would match them\n// against half of a surrogate pair.\nconst compileAffixes = tokens => {\n let prefix = \"\";\n let suffix;\n for (const token of tokens) {\n if (token._tag === \"Star\" && suffix === undefined) {\n suffix = \"\";\n } else if (token._tag === \"Char\" && (token.code < 0xd800 || token.code > 0xdfff)) {\n const char = String.fromCodePoint(token.code);\n if (suffix === undefined) {\n prefix += char;\n } else {\n suffix += char;\n }\n } else {\n return undefined;\n }\n }\n return suffix === undefined ? undefined : {\n prefix,\n suffix\n };\n};\nconst range = (from, to) => [from.codePointAt(0), to.codePointAt(0)];\nconst posixClasses = {\n alnum: [... /*#__PURE__*/range(\"0\", \"9\"), ... /*#__PURE__*/range(\"A\", \"Z\"), ... /*#__PURE__*/range(\"a\", \"z\")],\n alpha: [... /*#__PURE__*/range(\"A\", \"Z\"), ... /*#__PURE__*/range(\"a\", \"z\")],\n blank: [0x09, 0x09, 0x20, 0x20],\n cntrl: [0x00, 0x1f, 0x7f, 0x7f],\n digit: /*#__PURE__*/range(\"0\", \"9\"),\n graph: [0x21, 0x7e],\n lower: /*#__PURE__*/range(\"a\", \"z\"),\n print: [0x20, 0x7e],\n punct: [0x21, 0x2f, 0x3a, 0x40, 0x5b, 0x60, 0x7b, 0x7e],\n space: [0x09, 0x0d, 0x20, 0x20],\n upper: /*#__PURE__*/range(\"A\", \"Z\"),\n word: [... /*#__PURE__*/range(\"0\", \"9\"), ... /*#__PURE__*/range(\"A\", \"Z\"), 0x5f, 0x5f, ... /*#__PURE__*/range(\"a\", \"z\")],\n xdigit: [... /*#__PURE__*/range(\"0\", \"9\"), ... /*#__PURE__*/range(\"A\", \"F\"), ... /*#__PURE__*/range(\"a\", \"f\")]\n};\n// POSIX class names are at most six characters.\nconst parsePosixClass = (chars, open) => {\n for (let i = open + 2; i < chars.length && i <= open + 8; i++) {\n if (chars[i] === \":\" && chars[i + 1] === \"]\") {\n const ranges = posixClasses[chars.slice(open + 2, i).join(\"\")];\n return ranges === undefined ? undefined : {\n ranges,\n end: i + 1\n };\n }\n }\n return undefined;\n};\n// Share class boundaries between brace expansion and segment compilation.\nconst parseClass = (chars, open) => {\n let i = open + 1;\n const negated = chars[i] === \"!\" || chars[i] === \"^\";\n if (negated) {\n i++;\n }\n const ranges = [];\n for (let first = true; i < chars.length; i++, first = false) {\n let char = chars[i];\n if (char === \"/\") {\n return undefined;\n }\n if (char === \"]\" && !first) {\n return {\n token: {\n _tag: \"Class\",\n ranges,\n negated\n },\n end: i\n };\n }\n if (char === \"[\" && chars[i + 1] === \":\") {\n const posix = parsePosixClass(chars, i);\n if (posix !== undefined) {\n ranges.push(...posix.ranges);\n i = posix.end;\n continue;\n }\n }\n if (char === \"\\\\\" && i + 1 < chars.length) {\n char = chars[++i];\n }\n if (chars[i + 1] === \"-\" && i + 2 < chars.length && chars[i + 2] !== \"]\") {\n let next = i + 2;\n if (chars[next] === \"/\") {\n return undefined;\n }\n if (chars[next] === \"\\\\\" && next + 1 < chars.length) {\n next++;\n }\n ranges.push(...range(char, chars[next]));\n i = next;\n continue;\n }\n ranges.push(...range(char, char));\n }\n return undefined;\n};\nconst expandBraces = pattern => {\n const chars = Array.from(pattern);\n const groups = matchBraceGroups(chars);\n if (groups.size === 0) {\n return [pattern];\n }\n const sequence = parseBraceSequence(chars, 0, chars.length, groups, 0);\n if (sequence === undefined) {\n return [pattern];\n }\n const count = countExpansions(sequence);\n return count > maxExpansions || count * pattern.length > maxExpandedLength ? [pattern] : expandSequence(sequence);\n};\n// Index expandable brace groups by opening position, ignoring bracket classes.\nconst matchBraceGroups = chars => {\n const groups = new Map();\n const stack = [];\n let classes = true;\n for (let i = 0; i < chars.length; i++) {\n const char = chars[i];\n if (char === \"\\\\\") {\n i++;\n } else if (char === \"/\") {\n classes = true;\n } else if (char === \"[\" && classes) {\n const parsed = parseClass(chars, i);\n if (parsed === undefined) {\n classes = false;\n } else {\n i = parsed.end;\n }\n } else if (char === \"{\") {\n stack.push({\n open: i,\n commas: []\n });\n } else if (char === \",\") {\n stack[stack.length - 1]?.commas.push(i);\n } else if (char === \"}\") {\n const group = stack.pop();\n if (group !== undefined && group.commas.length > 0) {\n groups.set(group.open, {\n commas: group.commas,\n close: i\n });\n }\n }\n }\n return groups;\n};\nconst parseBraceSequence = (chars, start, end, groups, depth) => {\n if (depth > maxBraceDepth) {\n return undefined;\n }\n const parts = [];\n let text = \"\";\n for (let i = start; i < end; i++) {\n const group = groups.get(i);\n if (group === undefined) {\n if (chars[i] === \"\\\\\" && i + 1 < end) {\n text += chars[i++];\n }\n text += chars[i];\n continue;\n }\n const alternatives = [];\n let from = i + 1;\n for (const to of [...group.commas, group.close]) {\n const alternative = parseBraceSequence(chars, from, to, groups, depth + 1);\n if (alternative === undefined) {\n return undefined;\n }\n alternatives.push(alternative);\n from = to + 1;\n }\n if (text !== \"\") {\n parts.push(text);\n text = \"\";\n }\n parts.push(alternatives);\n i = group.close;\n }\n if (text !== \"\") {\n parts.push(text);\n }\n return parts;\n};\nconst countExpansions = sequence => {\n let count = 1;\n for (const part of sequence) {\n if (typeof part !== \"string\") {\n let sum = 0;\n for (const alternative of part) {\n sum += countExpansions(alternative);\n }\n count *= sum;\n if (count > maxExpansions) {\n return Infinity;\n }\n }\n }\n return count;\n};\nconst expandSequence = sequence => {\n let out = [\"\"];\n for (const part of sequence) {\n if (typeof part === \"string\") {\n out = out.map(prefix => prefix + part);\n } else {\n const alternatives = part.flatMap(expandSequence);\n out = out.flatMap(prefix => alternatives.map(alternative => prefix + alternative));\n }\n }\n return out;\n};\n// -----------------------------------------------------------------------------\n// matching\n// -----------------------------------------------------------------------------\nconst matchToken = (token, code) => {\n switch (token._tag) {\n case \"Char\":\n return token.code === code;\n case \"Any\":\n return true;\n case \"Star\":\n return false;\n case \"Class\":\n {\n let found = false;\n for (let i = 0; i < token.ranges.length && !found; i += 2) {\n found = code >= token.ranges[i] && code <= token.ranges[i + 1];\n }\n return found !== token.negated;\n }\n }\n};\n// UTF-16 length of the code point\nconst width = code => code > 0xffff ? 2 : 1;\n// Backtrack only to the last `*`, bounding retries by tokens × characters.\nconst matchWildcard = (node, name, dot) => {\n if (name === \".\" || name === \"..\" || name.startsWith(\".\") && !dot && !node.leadingDot) {\n return false;\n }\n if (node.affixes !== undefined) {\n const {\n prefix,\n suffix\n } = node.affixes;\n return name.length >= prefix.length + suffix.length && name.startsWith(prefix) && name.endsWith(suffix);\n }\n const {\n tokens\n } = node;\n let t = 0;\n let c = 0;\n let star = -1;\n let resume = 0;\n while (c < name.length) {\n if (tokens[t]?._tag === \"Star\") {\n star = t++;\n resume = c;\n continue;\n }\n const code = name.codePointAt(c);\n if (t < tokens.length && matchToken(tokens[t], code)) {\n t++;\n c += width(code);\n } else if (star !== -1) {\n t = star + 1;\n resume += width(name.codePointAt(resume));\n c = resume;\n } else {\n return false;\n }\n }\n while (tokens[t]?._tag === \"Star\") {\n t++;\n }\n return t === tokens.length;\n};\n// `**` also matches zero segments, so its successor is reachable too\nconst closure = (nodes, states) => {\n for (const state of states) {\n if (nodes[state]._tag === \"Globstar\") {\n states.add(state + 1);\n }\n }\n return states;\n};\nconst step = (compiled, states, name) => {\n const explicit = new Set();\n const viaGlobstar = new Set();\n // only a literal segment can name the root of an absolute path\n const root = isRoot(name);\n for (const state of states) {\n const node = compiled.nodes[state];\n switch (node._tag) {\n case \"Globstar\":\n {\n if (!root && name !== \".\" && name !== \"..\" && (compiled.dot || !name.startsWith(\".\"))) {\n viaGlobstar.add(state);\n }\n break;\n }\n case \"Literal\":\n {\n if (node.value === name) {\n explicit.add(state + 1);\n }\n break;\n }\n case \"Wildcard\":\n {\n if (!root && matchWildcard(node, name, compiled.dot)) {\n explicit.add(state + 1);\n }\n break;\n }\n }\n }\n return {\n explicit: closure(compiled.nodes, explicit),\n globstar: closure(compiled.nodes, viaGlobstar)\n };\n};\nconst union = step => {\n if (step.globstar.size === 0) {\n return step.explicit;\n }\n const states = new Set(step.explicit);\n for (const state of step.globstar) {\n states.add(state);\n }\n return states;\n};\nconst accepts = (compiled, states, isDirectory) => {\n for (const state of states) {\n const node = compiled.nodes[state];\n if (node._tag === \"End\" && (isDirectory || !node.directoryOnly)) {\n return true;\n }\n }\n return false;\n};\nconst canDescend = (compiled, states) => {\n for (const state of states) {\n if (compiled.nodes[state]._tag !== \"End\") {\n return true;\n }\n }\n return false;\n};\nconst needsDirectory = (compiled, states) => {\n for (const state of states) {\n const node = compiled.nodes[state];\n if (node._tag === \"End\" && node.directoryOnly) {\n return true;\n }\n }\n return false;\n};\n// `step` and `union` over bitmasks; a `**` node's successor is the next bit\nconst stepMasks = (compiled, masks, states, name, root) => {\n let next = !root && name !== \".\" && name !== \"..\" && (compiled.dot || !name.startsWith(\".\")) ? states & masks.globstar : 0;\n // the remaining states are `Literal` and `Wildcard` nodes\n let segments = states & ~(masks.globstar | masks.end);\n while (segments !== 0) {\n const bit = segments & -segments;\n segments ^= bit;\n const node = compiled.nodes[31 - Math.clz32(bit)];\n if (node._tag === \"Literal\" ? node.value === name : node._tag === \"Wildcard\" && !root && matchWildcard(node, name, compiled.dot)) {\n next |= bit << 1;\n }\n }\n return next | (next & masks.globstar) << 1;\n};\n/** @internal */\nexport const match = (compiled, path) => {\n if (path === \"\" || isUnc(path)) {\n return false;\n }\n const {\n masks\n } = compiled;\n if (masks === undefined) {\n const {\n directory,\n segments\n } = normalize(path.split(\"/\"));\n let states = compiled.initial;\n for (const name of segments) {\n states = union(step(compiled, states, name));\n if (states.size === 0) {\n return false;\n }\n }\n return accepts(compiled, states, directory);\n }\n // The same segments as `normalize(path.split(\"/\"))`, without the arrays\n let states = masks.initial;\n let stepped = false;\n let start = 0;\n let end = path.indexOf(\"/\");\n if (end === 0 || end === 2 && drive.test(path)) {\n states = stepMasks(compiled, masks, states, path.slice(0, end === 0 ? 0 : 3), true);\n stepped = true;\n start = end + 1;\n end = path.indexOf(\"/\", start);\n }\n let directory = false;\n let dotted = false;\n while (states !== 0) {\n const name = end === -1 ? path.slice(start) : path.slice(start, end);\n if (name === \"\" || name === \".\") {\n dotted ||= name === \".\";\n directory = end === -1 && stepped;\n } else {\n states = stepMasks(compiled, masks, states, name, false);\n stepped = true;\n directory = false;\n }\n if (end === -1) {\n break;\n }\n start = end + 1;\n end = path.indexOf(\"/\", start);\n }\n if (!stepped && dotted) {\n states = stepMasks(compiled, masks, states, \".\", false);\n }\n return (states & (directory ? masks.end : masks.endFile)) !== 0;\n};\n// -----------------------------------------------------------------------------\n// file system walk\n// -----------------------------------------------------------------------------\nconst join = (parent, name) => {\n if (parent === \"\") {\n return name === \"\" ? \"/\" : name;\n }\n return parent.endsWith(\"/\") ? parent + name : `${parent}/${name}`;\n};\nconst isMissing = error => error.reason._tag === \"NotFound\" || error.reason._tag === \"BadResource\";\nconst isIgnorable = error => isMissing(error) || error.reason._tag === \"PermissionDenied\";\n// Node and Deno report `readLink` on a path that is not a link as \"Unknown\"\nconst isNotLink = error => isIgnorable(error) || error.reason._tag === \"Unknown\";\nconst DIRECTORY_CONCURRENCY = 16;\nconst byName = /*#__PURE__*/Order.mapInput(Order.String, entry => entry.name);\n/** @internal */\nexport const make = fs => (pattern, options) => walk(fs, compile([pattern], options?.dot ?? false), options);\n// Named directories (the root and those reached only through leading literal\n// segments) must be readable; unreadable wildcard-reached ones are skipped.\nconst walk = /*#__PURE__*/Effect.fnUntraced(function* (fs, compiled, options) {\n if (compiled.initial.size === 0) {\n return [];\n }\n const root = options?.root ?? \"\";\n const excludes = compile(options?.exclude ?? [], true);\n const excludeNeedsDirectory = excludes.nodes.some(node => node._tag === \"End\" && node.directoryOnly);\n const toFsPath = relative => isAbsolute(relative) ? relative : relative === \"\" ? root === \"\" ? \".\" : root : join(root, relative);\n // Listings never contain `.`, `..`, or the root of an absolute pattern\n const isUnlisted = value => value === \".\" || value === \"..\" || isRoot(value);\n // Keep broken links so literal probes agree with directory listings.\n const probe = (parent, name, named) => {\n const path = toFsPath(join(parent, name));\n return fs.stat(path).pipe(Effect.map(info => info.type), Effect.catchReason(\"PlatformError\", \"NotFound\", () => fs.readLink(path).pipe(Effect.as(\"SymbolicLink\"), Effect.catchIf(isNotLink, () => Effect.succeed(undefined)))), Effect.catchIf(named ? isMissing : isIgnorable, () => Effect.succeed(undefined)), Effect.map(type => type === undefined ? undefined : {\n name,\n type\n }));\n };\n // Probe leading literals without requiring permission to list their parent.\n const entries = (relative, states, named) => {\n const literals = new Set();\n let listed = !named;\n for (const state of states) {\n const node = compiled.nodes[state];\n if (node._tag === \"Literal\") {\n literals.add(node.value);\n } else if (node._tag !== \"End\") {\n listed = true;\n }\n }\n const probed = listed ? [...literals].filter(isUnlisted) : [...literals];\n return Effect.zipWith(listed ? Effect.catchIf(fs.readDirectoryEntries(toFsPath(relative)), named ? isMissing : isIgnorable, () => Effect.succeed([])) : Effect.succeed([]), Effect.forEach(probed, name => probe(relative, name, named), {\n concurrency: 16\n }), (listing, found) => ({\n entries: Arr.sort([...listing, ...found.filter(Predicate.isNotUndefined)], byName),\n named: named && !listed\n }));\n };\n // Synchronous unless the entry type must be resolved through `stat` / `readLink`\n const visit = ({\n name,\n type\n }, parent, states, excluded) => {\n const result = step(compiled, states, name);\n const next = union(result);\n if (next.size === 0) {\n return undefined;\n }\n const relative = join(parent, name);\n const nextExcluded = union(step(excludes, excluded, name));\n const descend = canDescend(compiled, next);\n const child = (isDirectory, link) => {\n const accepted = accepts(compiled, next, isDirectory);\n if (!accepted && (!isDirectory || !descend) || accepts(excludes, nextExcluded, isDirectory)) {\n return undefined;\n }\n return {\n relative,\n accepted,\n excluded: nextExcluded,\n next: !isDirectory || !descend ? undefined : !link || result.globstar.size === 0 ? next\n // Follow symlinks only through explicit segments, not `**`.\n : canDescend(compiled, result.explicit) ? result.explicit : undefined\n };\n };\n if (!descend && !needsDirectory(compiled, next) && !excludeNeedsDirectory) {\n return child(false, false);\n }\n if (type !== \"Unknown\" && type !== \"SymbolicLink\") {\n return child(type === \"Directory\", false);\n }\n const path = toFsPath(relative);\n return fs.stat(path).pipe(Effect.map(info => info.type === \"Directory\"), Effect.catchIf(isIgnorable, () => Effect.succeed(false)), Effect.flatMap(isDirectory => {\n const resolved = child(isDirectory, type === \"SymbolicLink\");\n if (type === \"SymbolicLink\" || resolved?.next === undefined || result.globstar.size === 0) {\n return Effect.succeed(resolved);\n }\n return fs.readLink(path).pipe(Effect.as(child(isDirectory, true)), Effect.catchIf(isNotLink, () => Effect.succeed(resolved)));\n }));\n };\n // Walk subdirectories in forked fibers while slots are free and inline\n // otherwise, bounding directory reads in flight across the whole walk. A\n // forked walk reports its failure through `failed` so the whole walk ends\n // promptly even while its parent is walking another subdirectory inline.\n // Once the root walk is finishing, forked walks only exit because it\n // interrupts them.\n let slots = DIRECTORY_CONCURRENCY;\n let finishing = false;\n const failed = Deferred.makeUnsafe();\n const fork = walk => walk.pipe(Effect.onError(cause => Effect.sync(() => {\n if (!finishing) {\n Deferred.doneUnsafe(failed, Effect.failCause(cause));\n }\n })), Effect.ensuring(Effect.sync(() => {\n slots++;\n })), Effect.forkChild);\n const directory = Effect.fnUntraced(function* (relative, states, excluded, named) {\n const listing = yield* entries(relative, states, named);\n const children = [];\n const pending = [];\n for (const entry of listing.entries) {\n const child = visit(entry, relative, states, excluded);\n if (Effect.isEffect(child)) {\n const index = children.push(undefined) - 1;\n pending.push(Effect.map(child, child => {\n children[index] = child;\n }));\n } else {\n children.push(child);\n }\n }\n if (pending.length > 0) {\n yield* Effect.all(pending, {\n concurrency: 16,\n discard: true\n });\n }\n const subtrees = [];\n for (const child of children) {\n if (child?.next !== undefined) {\n const walk = directory(child.relative, child.next, child.excluded, listing.named);\n if (slots > 0) {\n slots--;\n subtrees.push(Fiber.join(yield* fork(walk)));\n } else {\n subtrees.push(Effect.succeed(yield* walk));\n }\n }\n }\n // Splice subtrees back in listing order\n const out = [];\n let index = 0;\n for (const child of children) {\n if (child === undefined) {\n continue;\n }\n if (child.accepted) {\n out.push(child.relative);\n }\n if (child.next !== undefined) {\n for (const path of yield* subtrees[index++]) {\n out.push(path);\n }\n }\n }\n return out;\n });\n // The losing walk is interrupted along with every fiber it forked\n return yield* Effect.raceFirst(Effect.ensuring(directory(\"\", compiled.initial, excludes.initial, true), Effect.sync(() => {\n finishing = true;\n })), Deferred.await(failed));\n});\n//# sourceMappingURL=glob.js.map",
|
|
25
|
+
"/**\n * Normalized errors for platform APIs.\n *\n * Platform services such as file systems, terminals, and sockets use\n * `PlatformError` to report host-level failures in a consistent shape. The\n * wrapper records whether the problem came from an invalid argument or from the\n * operating system, while preserving useful details such as the module, method,\n * path, descriptor, description, and original cause when available.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Data from \"./Data.js\";\nimport * as Predicate from \"./Predicate.js\";\nconst TypeId = \"~effect/PlatformError\";\n/**\n * Error data for an invalid argument passed to a platform API.\n *\n * **When to use**\n *\n * Use when you need to model caller input rejected before a platform operation\n * runs, including invalid-argument reason data.\n *\n * **Details**\n *\n * The error records the module and method that rejected the argument, with an\n * optional description and cause. It is usually wrapped in `PlatformError`.\n *\n * @see {@link badArgument} for creating a wrapped `PlatformError` whose reason is `BadArgument`\n * @see {@link SystemError} for failures reported by the host platform or operating system\n * @see {@link PlatformError} for the wrapper used by most platform APIs\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class BadArgument extends /*#__PURE__*/Data.TaggedError(\"BadArgument\") {\n /**\n * Formats the module, method, and optional description that rejected the argument.\n *\n * **When to use**\n *\n * Use to read the formatted error message for a rejected platform argument.\n *\n * @since 4.0.0\n */\n get message() {\n return `${this.module}.${this.method}${this.description ? `: ${this.description}` : \"\"}`;\n }\n}\n/**\n * Error data for a platform or system operation failure.\n *\n * **When to use**\n *\n * Use when you need normalized reason data for a platform or system operation\n * failure, including the operation details.\n *\n * **Details**\n *\n * The error records a normalized `_tag`, the module and method that failed,\n * and optional details such as the syscall, path or descriptor, description,\n * and original cause. It is usually wrapped in `PlatformError`.\n *\n * @see {@link systemError} for creating the usual `PlatformError` wrapper from this reason data\n * @see {@link BadArgument} for platform API failures caused by rejected caller input before an operation runs\n * @see {@link SystemErrorTag} for the normalized tag values stored in `_tag`\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class SystemError extends Data.Error {\n /**\n * Formats the normalized system error tag with operation and path details.\n *\n * **When to use**\n *\n * Use to read the formatted error message for a normalized system failure.\n *\n * @since 4.0.0\n */\n get message() {\n return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== undefined ? ` (${this.pathOrDescriptor})` : \"\"}${this.description ? `: ${this.description}` : \"\"}`;\n }\n}\n/**\n * Tagged error used by platform APIs to report either invalid arguments or\n * system-level failures.\n *\n * **When to use**\n *\n * Use as the shared error type for platform APIs that expose invalid arguments\n * and host or operating-system failures through a single `Effect` error\n * channel.\n *\n * **Details**\n *\n * The `reason` field contains the underlying `BadArgument` or `SystemError`.\n * When that reason has a cause, the cause is preserved on the wrapper.\n *\n * @see {@link BadArgument} for invalid inputs rejected before an operation runs\n * @see {@link SystemError} for failures reported by the host platform or operating system\n * @see {@link badArgument} for creating this wrapper from rejected caller input\n * @see {@link systemError} for creating this wrapper from a host or operating-system failure\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class PlatformError extends /*#__PURE__*/Data.TaggedError(\"PlatformError\") {\n constructor(reason) {\n if (\"cause\" in reason) {\n super({\n reason,\n cause: reason.cause\n });\n } else {\n super({\n reason\n });\n }\n }\n /**\n * Marks this value as a platform error wrapper for runtime guards.\n *\n * **When to use**\n *\n * Use to identify `PlatformError` values through their runtime type marker.\n *\n * @since 4.0.0\n */\n [TypeId] = TypeId;\n get message() {\n return this.reason.message;\n }\n}\n/**\n * Returns `true` if a value is a `PlatformError`.\n *\n * **When to use**\n *\n * Use to narrow a caught defect, or an error channel typed more loosely than\n * the platform APIs, to `PlatformError`.\n *\n * **Example** (Checking a caught value)\n *\n * ```ts import.meta.vitest\n * import { PlatformError } from \"effect\"\n *\n * const error = PlatformError.badArgument({\n * module: \"FileSystem\",\n * method: \"readFile\"\n * })\n *\n * PlatformError.isPlatformError(error) // => true\n * PlatformError.isPlatformError(new Error(\"boom\")) // => false\n * ```\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPlatformError = u => Predicate.hasProperty(u, TypeId);\n/**\n * Creates a `PlatformError` whose reason is a `SystemError`.\n *\n * **When to use**\n *\n * Use to adapt an operating-system or platform failure into the normalized\n * platform error model.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const systemError = options => new PlatformError(new SystemError(options));\n/**\n * Creates a `PlatformError` whose reason is a `BadArgument`.\n *\n * **When to use**\n *\n * Use to report a platform API rejecting caller input before performing the\n * underlying operation.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const badArgument = options => new PlatformError(new BadArgument(options));\n//# sourceMappingURL=PlatformError.js.map",
|
|
26
|
+
"import * as Arr from \"./Array.js\";\nimport * as Cause from \"./Cause.js\";\nimport * as Channel from \"./Channel.js\";\nimport * as Clock from \"./Clock.js\";\nimport * as Duration from \"./Duration.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport { constant, constFalse, constTrue, constVoid, dual, identity, pipe } from \"./Function.js\";\nimport * as Count from \"./internal/count.js\";\nimport * as internalStream from \"./internal/stream.js\";\nimport * as Option from \"./Option.js\";\nimport { pipeArguments } from \"./Pipeable.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as PubSub from \"./PubSub.js\";\nimport * as Pull from \"./Pull.js\";\nimport * as Queue from \"./Queue.js\";\nimport * as Result from \"./Result.js\";\nimport * as Scope from \"./Scope.js\";\nconst TypeId = \"~effect/Sink\";\nconst endVoid = /*#__PURE__*/Effect.succeed([void 0]);\nconst sinkVariance = {\n _A: identity,\n _In: identity,\n _L: identity,\n _E: identity,\n _R: identity\n};\nconst SinkProto = {\n [TypeId]: sinkVariance,\n pipe() {\n return pipeArguments(this, arguments);\n }\n};\n/**\n * Checks whether a value is a Sink.\n *\n * **Example** (Checking for a sink)\n *\n * ```ts import.meta.vitest\n * import { Sink } from \"effect\"\n *\n * const sink = Sink.never\n * const notStream = { data: [1, 2, 3] }\n *\n * Sink.isSink(sink) // => true\n * Sink.isSink(notStream) // => false\n * ```\n *\n * @stability stable\n * @category guards\n * @since 4.0.0\n */\nexport const isSink = u => hasProperty(u, TypeId);\n/**\n * Creates a sink from a `Channel`.\n *\n * **When to use**\n *\n * Use to create a `Sink` from a `Channel` that processes non-empty arrays of\n * input values.\n *\n * **Example** (Using channel completion as the sink result)\n *\n * ```ts import.meta.vitest\n * import { Channel, Effect, Sink, Stream } from \"effect\"\n *\n * const channel = Channel.identity<readonly [number, ...Array<number>], never, void>().pipe(\n * Channel.drain,\n * Channel.mapDone(() => [\"consumed\"] as const)\n * )\n * const sink = Sink.fromChannel(channel)\n *\n * await Effect.runPromise(Stream.run(Stream.make(1, 2, 3), sink)) // => \"consumed\"\n * ```\n *\n * @see {@link toChannel} for converting a `Sink` back to a `Channel`\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const fromChannel = channel => fromTransform((upstream, scope) => Channel.toTransform(channel)(upstream, scope).pipe(Effect.flatMap(Effect.forever({\n disableYield: true\n})), Pull.catchDone(Effect.succeed)));\n/**\n * Creates a sink that writes its input to a Web `WritableStream`.\n *\n * **Example** (Collecting values in a Web stream)\n *\n * ```ts import.meta.vitest\n * import { Effect, Sink, Stream } from \"effect\"\n *\n * const written: Array<number> = []\n * const sink = Sink.fromWritableStream({\n * evaluate: () => new WritableStream<number>({\n * write(value) {\n * written.push(value)\n * }\n * }),\n * onError: (cause) => new Error(String(cause))\n * })\n *\n * await Effect.runPromise(Stream.run(Stream.make(1, 2, 3), sink))\n * written // => [1, 2, 3]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromWritableStream = options => fromChannel(Channel.mapDone(Channel.fromWritableStream(options), _ => [_]));\n/**\n * Creates a `Sink` from a low-level transform function.\n *\n * **Details**\n *\n * The transform receives the upstream pull of non-empty input arrays and the\n * active scope, and returns an effect that completes with the sink's `End`\n * value.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromTransform = transform => {\n const self = Object.create(SinkProto);\n self.transform = transform;\n return self;\n};\n/**\n * Creates a `Channel` from a Sink.\n *\n * **Example** (Running a sink as a channel)\n *\n * ```ts import.meta.vitest\n * import { Channel, Effect, Sink, Stream } from \"effect\"\n *\n * const channel = Stream.toChannel(Stream.make(1, 2, 3)).pipe(\n * Channel.pipeTo(Sink.toChannel(Sink.sum))\n * )\n *\n * await Effect.runPromise(Channel.runDrain(channel)) // => [6]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const toChannel = self => Channel.fromTransform((upstream, scope) => Effect.succeed(Effect.flatMap(self.transform(upstream, scope), Cause.done)));\n/**\n * Creates a pipe-style constructor for sinks over input type `In`.\n *\n * **Details**\n *\n * The returned function exposes the sink input as a `Stream<In>`, applies the\n * provided pipeline, and uses the final effect's success value as the sink\n * result.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = () => (...fns) => fromTransform((upstream, scope) => pipe(internalStream.fromChannel(Channel.fromPull(Effect.succeed(upstream))), ...fns, Effect.map(a => [a]), Scope.provide(scope)));\n/**\n * Creates a sink that ignores upstream input and completes from an effect that\n * already returns an `End`.\n *\n * **When to use**\n *\n * Use when you need to create a sink from an effect that returns both the sink\n * result value and optional leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromEffectEnd = effect => fromTransform(() => effect);\n/**\n * Creates a sink that ignores upstream input and completes with the success\n * value of the provided effect.\n *\n * **Details**\n *\n * If the effect fails, the sink fails with the same error.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const fromEffect = effect => fromEffectEnd(Effect.map(effect, a => [a]));\n/**\n * Creates a sink that offers every consumed input element to a queue.\n *\n * **Details**\n *\n * When the upstream stream ends, the sink ends the queue and completes with\n * `void`.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const fromQueue = queue => fromTransform(upstream => upstream.pipe(Effect.flatMap(arr => Queue.offerAll(queue, arr)), Effect.forever({\n disableYield: true\n}), Pull.catchDone(_ => {\n Queue.endUnsafe(queue);\n return endVoid;\n})));\n/**\n * Creates a sink that publishes every consumed input element to a `PubSub`.\n *\n * **Details**\n *\n * The sink completes with `void` when the upstream stream ends.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const fromPubSub = pubsub => forEachArray(arr => PubSub.publishAll(pubsub, arr));\n/**\n * A sink that immediately ends with the specified value.\n *\n * **Example** (Succeeding with a value)\n *\n * ```ts import.meta.vitest\n * import { Effect, Sink, Stream } from \"effect\"\n *\n * // Create a sink that always yields the same value\n * const sink = Sink.succeed(42)\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromise(Stream.run(stream, sink)) // => 42\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const succeed = (a, leftovers) => fromEffectEnd(Effect.succeed([a, leftovers]));\n/**\n * A sink that immediately ends with the specified lazily evaluated value.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const sync = a => fromEffect(Effect.sync(a));\n/**\n * A sink that is created from a lazily evaluated sink.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const suspend = evaluate => fromTransform((upstream, scope) => evaluate().transform(upstream, scope));\n/**\n * A sink that always fails with the specified error.\n *\n * **Example** (Failing with an error)\n *\n * ```ts import.meta.vitest\n * import { Effect, Exit, Sink, Stream } from \"effect\"\n *\n * // Create a sink that always fails\n * const sink = Sink.fail(\"Sink failed\")\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromiseExit(Stream.run(stream, sink)) // => Exit.fail(\"Sink failed\")\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const fail = e => fromEffectEnd(Effect.fail(e));\n/**\n * A sink that always fails with the specified lazily evaluated error.\n *\n * **Example** (Failing with a lazy error)\n *\n * ```ts import.meta.vitest\n * import { Effect, Exit, Sink, Stream } from \"effect\"\n *\n * // Create a sink that fails with a lazy error\n * const sink = Sink.failSync(() => \"Lazy error\")\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromiseExit(Stream.run(stream, sink)) // => Exit.fail(\"Lazy error\")\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const failSync = evaluate => fromEffectEnd(Effect.failSync(evaluate));\n/**\n * Creates a sink halting with a specified `Cause`.\n *\n * **Example** (Failing with a cause)\n *\n * ```ts import.meta.vitest\n * import { Cause, Effect, Exit, Sink, Stream } from \"effect\"\n *\n * // Create a sink that fails with a specific cause\n * const sink = Sink.failCause(Cause.fail(\"Custom cause\"))\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromiseExit(Stream.run(stream, sink)) // => Exit.fail(\"Custom cause\")\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const failCause = cause => fromEffectEnd(Effect.failCause(cause));\n/**\n * Creates a sink halting with a specified lazily evaluated `Cause`.\n *\n * **Example** (Failing with a lazy cause)\n *\n * ```ts import.meta.vitest\n * import { Cause, Effect, Exit, Sink, Stream } from \"effect\"\n *\n * // Create a sink that fails with a lazy cause\n * const sink = Sink.failCauseSync(() => Cause.fail(\"Lazy cause\"))\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromiseExit(Stream.run(stream, sink)) // => Exit.fail(\"Lazy cause\")\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const failCauseSync = evaluate => fromEffectEnd(Effect.failCauseSync(evaluate));\n/**\n * Creates a sink halting with a specified defect.\n *\n * **Example** (Dying with a defect)\n *\n * ```ts import.meta.vitest\n * import { Effect, Exit, Sink, Stream } from \"effect\"\n *\n * // Create a sink that dies with a defect\n * const sink = Sink.die(\"Defect error\")\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromiseExit(Stream.run(stream, sink)) // => Exit.die(\"Defect error\")\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const die = defect => fromEffectEnd(Effect.die(defect));\n/**\n * A sink that never completes.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const never = /*#__PURE__*/fromEffectEnd(Effect.never);\n/**\n * Drops leftovers produced by a sink.\n *\n * **Details**\n *\n * The sink result is preserved, but any leftover elements are discarded\n * instead of being returned to downstream sink composition. This does not\n * continue pulling additional elements from the upstream stream.\n *\n * @stability stable\n * @category filtering\n * @since 2.0.0\n */\nexport const ignoreLeftover = self => mapEnd(self, ([a]) => [a]);\n/**\n * Consumes and ignores all stream inputs.\n *\n * **When to use**\n *\n * Use to consume all upstream input and complete with void when the input\n * values and any aggregate result are not needed.\n *\n * @see {@link count} for consuming all input while returning the number of elements\n * @see {@link forEach} for consuming all input while running an effect for each element\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const drain = /*#__PURE__*/fromTransform(upstream => Pull.catchDone(Effect.forever(upstream, {\n disableYield: true\n}), () => endVoid));\n/**\n * A sink that folds its inputs with the provided function, termination\n * predicate and initial state.\n *\n * **When to use**\n *\n * Use to accumulate stream input element by element with an effectful step and\n * stop based on the accumulated state.\n *\n * **Details**\n *\n * The initial state is evaluated lazily. Each input element is folded with the\n * effectful function, and the sink continues while `contFn` returns `true`. If\n * the sink stops in the middle of a pulled array, the remaining elements from\n * that array are returned as leftovers.\n *\n * @see {@link foldArray} for folding each pulled non-empty input array at once\n * @see {@link foldUntil} for folding until a fixed maximum number of elements is consumed\n *\n * @stability stable\n * @category folding\n * @since 2.0.0\n */\nexport const fold = (s, contFn, f) => fromTransform(upstream => {\n let state = s();\n return Effect.gen(function* () {\n while (true) {\n const arr = yield* upstream;\n for (let i = 0; i < arr.length; i++) {\n state = yield* f(state, arr[i]);\n if (contFn(state)) continue;\n return [state, i + 1 < arr.length ? arr.slice(i + 1) : undefined];\n }\n }\n }).pipe(Pull.catchDone(() => Effect.succeed([state])));\n});\n/**\n * Folds non-empty input arrays into state with an effectful function.\n *\n * **When to use**\n *\n * Use to update state with an effectful function once per pulled non-empty\n * input array when batch-level processing is the natural unit.\n *\n * **Details**\n *\n * The initial state is evaluated lazily. After each pulled array is folded,\n * the sink continues while `contFn` returns `true`; otherwise it completes\n * with the current state.\n *\n * @see {@link fold} for folding element by element and returning leftovers when stopping mid-array\n * @see {@link reduceWhileArrayEffect} for array-level effectful reducing that checks the predicate before consuming input\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const foldArray = (s, contFn, f) => fromTransform(upstream => {\n let state = s();\n return Effect.gen(function* () {\n while (true) {\n const arr = yield* upstream;\n state = yield* f(state, arr);\n if (contFn(state)) continue;\n return [state];\n }\n }).pipe(Pull.catchDone(() => Effect.succeed([state])));\n});\n/**\n * Folds input elements into state until the specified maximum number of\n * elements has been consumed or the upstream stream ends.\n *\n * **Details**\n *\n * Finite fractional values of `max` are rounded down. If `max` is `NaN` or\n * non-positive, the sink completes with the initial state without consuming\n * input.\n *\n * If the sink stops in the middle of a pulled array, the remaining elements\n * from that array are returned as leftovers.\n *\n * @stability stable\n * @category folding\n * @since 2.0.0\n */\nexport const foldUntil = (s, max, f) => {\n const count = Count.normalize(max);\n if (count === 0) return sync(s);\n return fold(() => [s(), 0], tuple => tuple[1] < count, ([output, consumed], input) => Effect.map(f(output, input), s => [s, consumed + 1])).pipe(map(tuple => tuple[0]));\n};\n/**\n * A sink that returns whether all elements satisfy the specified predicate.\n *\n * **When to use**\n *\n * Use to reduce a stream to a boolean that is true only when every input\n * satisfies a pure predicate.\n *\n * @see {@link some} for the dual any-match check\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const every = predicate => fold(constTrue, identity, (_, a) => Effect.succeed(predicate(a)));\n/**\n * A sink that returns whether an element satisfies the specified predicate.\n *\n * **When to use**\n *\n * Use to reduce a stream to a boolean that is true when any input satisfies a\n * pure predicate.\n *\n * @see {@link every} for the all-match check\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const some = predicate => fold(constFalse, b => !b, (_, a) => Effect.succeed(predicate(a)));\n/**\n * Transforms this sink's result.\n *\n * **When to use**\n *\n * Use to compute a new result from the original sink result while preserving\n * the sink's input consumption behavior.\n *\n * **Details**\n *\n * The transformed sink preserves the original sink's input type, leftovers,\n * errors, and requirements.\n *\n * @see {@link mapEffect} for effectful result transformations\n * @see {@link as} for replacing the result with a constant value\n * @see {@link mapEnd} for transforming both the result and leftovers\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const map = /*#__PURE__*/dual(2, (self, f) => mapEnd(self, ([a, l]) => [f(a), l]));\n/**\n * Sets the sink's result to a constant value.\n *\n * **When to use**\n *\n * Use to keep a sink's input consumption, errors, requirements, and leftovers\n * while replacing only its result with a known value.\n *\n * @see {@link map} for computing the replacement from the original result\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const as = /*#__PURE__*/dual(2, (self, a2) => map(self, () => a2));\n/**\n * Transforms this sink's input elements.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const mapInput = /*#__PURE__*/dual(2, (self, f) => mapInputArray(self, Arr.map(f)));\n/**\n * Transforms this sink's input elements effectfully.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const mapInputEffect = /*#__PURE__*/dual(2, (self, f) => mapInputArrayEffect(self, Effect.forEach(f)));\n/**\n * Transforms each non-empty array of upstream input before it is fed to this\n * sink.\n *\n * @stability stable\n * @category mapping\n * @since 4.0.0\n */\nexport const mapInputArray = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => self.transform(Effect.map(upstream, f), scope)));\n/**\n * Transforms each non-empty array of upstream input effectfully before it is\n * fed to this sink.\n *\n * @stability stable\n * @category mapping\n * @since 4.0.0\n */\nexport const mapInputArrayEffect = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => self.transform(Effect.flatMap(upstream, f), scope)));\n/**\n * Transforms the full `End` produced by this sink.\n *\n * **Details**\n *\n * This can change both the result value and the optional leftovers.\n *\n * @stability stable\n * @category mapping\n * @since 4.0.0\n */\nexport const mapEnd = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => Effect.map(self.transform(upstream, scope), f)));\nconst transformEffect = (self, f) => fromTransform((upstream, scope) => f(self.transform(upstream, scope)));\n/**\n * Transforms the full `End` produced by this sink effectfully.\n *\n * **Details**\n *\n * This can change both the result value and the optional leftovers, and the\n * transformation can fail or require services.\n *\n * @stability stable\n * @category mapping\n * @since 4.0.0\n */\nexport const mapEffectEnd = /*#__PURE__*/dual(2, (self, f) => transformEffect(self, Effect.flatMap(f)));\n/**\n * Transforms this sink's result effectfully.\n *\n * **When to use**\n *\n * Use when you need a sink result transformation that is effectful, can fail,\n * or requires services.\n *\n * **Details**\n *\n * The transformed sink preserves the original sink's input consumption and\n * leftovers while adding the errors and requirements of the transformation.\n *\n * @see {@link map} for pure result transformations\n * @see {@link mapEffectEnd} for effectfully transforming both the result and leftovers\n * @see {@link flatMap} for continuing with another sink based on the result\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const mapEffect = /*#__PURE__*/dual(2, (self, f) => mapEffectEnd(self, ([a, l]) => Effect.map(f(a), a2 => [a2, l])));\n/**\n * Transforms the errors emitted by this sink using `f`.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const mapError = /*#__PURE__*/dual(2, (self, f) => transformEffect(self, Effect.mapError(f)));\n/**\n * Transforms the leftovers emitted by this sink using `f`.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const mapLeftover = /*#__PURE__*/dual(2, (self, f) => mapEnd(self, ([a, l]) => [a, l && Arr.map(l, f)]));\n/**\n * Collects up to `n` input elements into an array.\n *\n * **Details**\n *\n * Finite fractional values of `n` are rounded down. If `n` is `NaN` or\n * non-positive, the sink completes with an empty array. If more elements are\n * pulled than needed, the remaining elements from the same array are returned\n * as leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const take = n => {\n const count = Count.normalize(n);\n return fromTransform(upstream => {\n const taken = [];\n if (count === 0) {\n return Effect.succeed([taken]);\n }\n let leftover = undefined;\n return upstream.pipe(Effect.flatMap(arr => {\n if (taken.length + arr.length <= count) {\n for (let i = 0; i < arr.length; i++) {\n taken.push(arr[i]);\n }\n if (taken.length === count) {\n return Cause.done();\n }\n return Effect.void;\n }\n for (let i = 0; i < arr.length; i++) {\n taken.push(arr[i]);\n if (taken.length === count) {\n if (i + 1 < arr.length) {\n leftover = arr.slice(i + 1);\n }\n return Cause.done();\n }\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([taken, leftover])));\n });\n};\n/**\n * Runs this sink until it yields a result, then uses that result to create\n * another sink from the provided function which will continue to run until it\n * yields a result.\n *\n * **When to use**\n *\n * Use to compose sinks when the next sink depends on the result produced by the\n * previous sink.\n *\n * **Details**\n *\n * Leftovers from the first sink are fed to the sink returned by `f` before more\n * upstream input is pulled.\n *\n * @see {@link map} for transforming the result without switching sinks\n * @see {@link mapEffect} for effectfully transforming the result without switching sinks\n *\n * @stability stable\n * @category sequencing\n * @since 2.0.0\n */\nexport const flatMap = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => {\n let upstreamDone = false;\n const pull = Effect.catchCause(upstream, cause => {\n upstreamDone = true;\n return Effect.failCause(cause);\n });\n return Effect.flatMap(self.transform(pull, scope), ([a, leftover]) => f(a).transform(Effect.suspend(() => {\n if (leftover) {\n const arr = leftover;\n leftover = undefined;\n return Effect.succeed(arr);\n } else if (upstreamDone) {\n return Cause.done();\n }\n return upstream;\n }), scope).pipe(Effect.map(end => {\n if (!leftover) {\n return end;\n }\n return [end[0], end[1] ? [...end[1], ...leftover] : leftover];\n })));\n}));\n/**\n * A sink that reduces input elements from the provided `initial` state with\n * `f` while the specified `predicate` returns `true`.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceWhile = (initial, predicate, f) => fromTransform(upstream => {\n let state = initial();\n let leftover = undefined;\n if (!predicate(state)) {\n return Effect.succeed([state]);\n }\n return upstream.pipe(Effect.flatMap(arr => {\n for (let i = 0; i < arr.length; i++) {\n state = f(state, arr[i]);\n if (!predicate(state)) {\n if (i + 1 < arr.length) {\n leftover = arr.slice(i + 1);\n }\n return Cause.done();\n }\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([state, leftover])));\n});\n/**\n * A sink that effectfully reduces input elements from the provided `initial`\n * state with `f` while the specified `predicate` returns `true`.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceWhileEffect = (initial, predicate, f) => fromTransform(upstream => {\n let state = initial();\n let leftover = undefined;\n if (!predicate(state)) {\n return Effect.succeed([state]);\n }\n return upstream.pipe(Effect.flatMap(arr => {\n let i = 0;\n return Effect.whileLoop({\n while: () => i < arr.length,\n body: constant(Effect.flatMap(Effect.suspend(() => f(state, arr[i++])), s => {\n state = s;\n if (!predicate(state)) {\n if (i < arr.length) {\n leftover = arr.slice(i);\n }\n return Cause.done();\n }\n return Effect.void;\n })),\n step: constVoid\n });\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([state, leftover])));\n});\n/**\n * A sink that reduces non-empty input arrays from the provided `initial` state\n * with `f` while the specified `predicate` returns `true`.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceWhileArray = (initial, contFn, f) => fromTransform(upstream => {\n let state = initial();\n if (!contFn(state)) {\n return Effect.succeed([state]);\n }\n return upstream.pipe(Effect.flatMap(arr => {\n state = f(state, arr);\n if (!contFn(state)) {\n return Cause.done();\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([state])));\n});\n/**\n * A sink that effectfully reduces non-empty input arrays from the provided\n * `initial` state with `f` while the specified `predicate` returns `true`.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceWhileArrayEffect = (initial, predicate, f) => fromTransform(upstream => {\n let state = initial();\n if (!predicate(state)) {\n return Effect.succeed([state]);\n }\n return upstream.pipe(Effect.flatMap(arr => f(state, arr)), Effect.flatMap(s => {\n state = s;\n if (!predicate(state)) {\n return Cause.done();\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([state])));\n});\n/**\n * A sink that reduces its inputs using the provided function `f` starting from\n * the provided `initial` state.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduce = (initial, f) => reduceArray(initial, (s, arr) => {\n for (let i = 0; i < arr.length; i++) {\n s = f(s, arr[i]);\n }\n return s;\n});\n/**\n * A sink that reduces its inputs using the provided function `f` starting from\n * the specified `initial` state.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceArray = (initial, f) => fromTransform(upstream => {\n let state = initial();\n return upstream.pipe(Effect.flatMap(arr => {\n state = f(state, arr);\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([state])));\n});\n/**\n * A sink that reduces its inputs using the provided effectful function `f`\n * starting from the specified `initial` state.\n *\n * @stability stable\n * @category folding\n * @since 4.0.0\n */\nexport const reduceEffect = (initial, f) => reduceWhileEffect(initial, constTrue, f);\nconst head_ = /*#__PURE__*/reduceWhile(Option.none, Option.isNone, (_, in_) => Option.some(in_));\n/**\n * Creates a sink containing the first value.\n *\n * **Details**\n *\n * Returns `Option.some(first)` for non-empty input, or `Option.none` when the\n * upstream ends without input. The first element is consumed; later elements\n * from the same pulled array are emitted as leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const head = () => head_;\nconst last_ = /*#__PURE__*/reduceArray(Option.none, (_, arr) => Arr.last(arr));\n/**\n * Creates a sink containing the last value.\n *\n * **When to use**\n *\n * Use when you need to consume all upstream input and keep only the final\n * element.\n *\n * **Details**\n *\n * Returns `Option.some(last)` with the final input value, or `Option.none` when\n * the upstream ends without input.\n *\n * **Gotchas**\n *\n * This sink produces a result only when the upstream ends, so it does not\n * complete for a stream that does not end.\n *\n * @see {@link head} for taking the first input value instead\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const last = () => last_;\n/**\n * Creates a sink containing the first value matched by a synchronous predicate.\n *\n * **When to use**\n *\n * Use to scan stream input until the first matching element is found and return\n * that element as an `Option`.\n *\n * **Details**\n *\n * Returns `Option.none` if the upstream stream ends before a match is found.\n * Refinement predicates narrow the returned value type. The matching input is\n * consumed; any later elements from the same pulled array are returned as\n * leftovers.\n *\n * @see {@link findEffect} for an effectful predicate that can fail or require services\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const find = predicate => reduceWhile(Option.none, Option.isNone, (acc, in_) => predicate(in_) ? Option.some(in_) : acc);\n/**\n * Creates a sink containing the first value matched by an effectful predicate.\n *\n * **When to use**\n *\n * Use when you need to run effects, fail, or use services while searching for\n * the first matching input.\n *\n * **Details**\n *\n * Returns `Option.some` with the first input whose predicate result is `true`,\n * or `Option.none` if the upstream stream ends first. If the predicate effect\n * fails, the sink fails with the same error.\n *\n * @see {@link find} for the synchronous predicate variant\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const findEffect = predicate => reduceWhileEffect(Option.none, Option.isNone, (acc, in_) => Effect.map(predicate(in_), b => b ? Option.some(in_) : acc));\n/**\n * Creates a sink which sums up its inputs.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const sum = /*#__PURE__*/reduceArray(() => 0, (s, arr) => {\n for (let i = 0; i < arr.length; i++) {\n s += arr[i];\n }\n return s;\n});\n/**\n * A sink that counts the number of elements fed to it.\n *\n * **When to use**\n *\n * Use to consume input and return only the number of elements received.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const count = /*#__PURE__*/reduceArray(() => 0, (s, arr) => s + arr.length);\n/**\n * Accumulates incoming elements into an array.\n *\n * **When to use**\n *\n * Use when you need a sink result containing all upstream input elements.\n *\n * @see {@link take} for collecting only a fixed number of input elements\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const collect = () => reduceArray(Arr.empty, (s, arr) => {\n for (let i = 0; i < arr.length; i++) {\n s.push(arr[i]);\n }\n return s;\n});\n/**\n * Collects the longest input prefix whose elements satisfy the predicate or\n * refinement.\n *\n * **Details**\n *\n * The first failing input is consumed and excluded from the result. Any later\n * elements from the same pulled array are returned as leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeWhile = predicate => fromTransform(upstream => {\n const out = Arr.empty();\n return upstream.pipe(Effect.flatMap(arr => {\n for (let i = 0; i < arr.length; i++) {\n if (!predicate(arr[i])) {\n const leftover = i + 1 < arr.length ? arr.slice(i + 1) : undefined;\n return Cause.done([out, leftover]);\n }\n out.push(arr[i]);\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(end => Effect.succeed(end ?? [out])));\n});\n/**\n * Applies a `Filter` to input elements while it succeeds, collecting each\n * successful output.\n *\n * **Details**\n *\n * The first input for which the filter fails is consumed and excluded from the\n * result. Any later elements from the same pulled array are returned as\n * leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeWhileFilter = filter => fromTransform(upstream => {\n const out = Arr.empty();\n return upstream.pipe(Effect.flatMap(arr => {\n for (let i = 0; i < arr.length; i++) {\n const result = filter(arr[i]);\n if (Result.isFailure(result)) {\n const leftover = i + 1 < arr.length ? arr.slice(i + 1) : undefined;\n return Cause.done([out, leftover]);\n }\n out.push(result.success);\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(end => Effect.succeed(end ?? [out])));\n});\n/**\n * Collects input elements effectfully while the predicate succeeds.\n *\n * **Details**\n *\n * The first input for which the predicate returns `false` is consumed and\n * excluded from the result. Any later elements from the same pulled array are\n * returned as leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeWhileEffect = predicate => fromTransform(upstream => {\n const out = Arr.empty();\n let leftover = undefined;\n return upstream.pipe(Effect.flatMap(arr => {\n let i = 0;\n return Effect.whileLoop({\n while: () => i < arr.length,\n body: constant(Effect.flatMap(Effect.suspend(() => {\n const input = arr[i++];\n return Effect.map(predicate(input), passes => [input, passes]);\n }), ([input, passes]) => {\n if (!passes) {\n if (i < arr.length) {\n leftover = arr.slice(i);\n }\n return Cause.done();\n }\n out.push(input);\n return Effect.void;\n })),\n step: constVoid\n });\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([out, leftover])));\n});\n/**\n * Applies a `FilterEffect` to input elements effectfully while it succeeds,\n * collecting each successful output.\n *\n * **Details**\n *\n * The first input for which the filter fails is consumed and excluded from the\n * result. Any later elements from the same pulled array are returned as\n * leftovers.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeWhileFilterEffect = filter => fromTransform(upstream => {\n const out = Arr.empty();\n let leftover = undefined;\n return upstream.pipe(Effect.flatMap(arr => {\n let i = 0;\n return Effect.whileLoop({\n while: () => i < arr.length,\n body: constant(Effect.flatMap(Effect.suspend(() => filter(arr[i++])), result => {\n if (Result.isFailure(result)) {\n if (i < arr.length) {\n leftover = arr.slice(i);\n }\n return Cause.done();\n }\n out.push(result.success);\n return Effect.void;\n })),\n step: constVoid\n });\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([out, leftover])));\n});\n/**\n * Collects input elements until the predicate returns `true`, including the\n * matching element in the result.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeUntil = predicate => fromTransform(upstream => {\n const out = Arr.empty();\n return upstream.pipe(Effect.flatMap(arr => {\n for (let i = 0; i < arr.length; i++) {\n out.push(arr[i]);\n if (predicate(arr[i])) {\n const leftover = i + 1 < arr.length ? arr.slice(i + 1) : undefined;\n return Cause.done([out, leftover]);\n }\n }\n return Effect.void;\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(end => Effect.succeed(end ?? [out])));\n});\n/**\n * Collects input elements effectfully until the predicate returns `true`,\n * including the matching element in the result.\n *\n * **Details**\n *\n * If the predicate effect fails, the sink fails with the same error.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const takeUntilEffect = predicate => fromTransform(upstream => {\n const out = Arr.empty();\n let leftover = undefined;\n return upstream.pipe(Effect.flatMap(arr => {\n let i = 0;\n return Effect.whileLoop({\n while: () => i < arr.length,\n body: () => {\n const input = arr[i++];\n return Effect.flatMap(predicate(input), matched => {\n out.push(input);\n if (!matched) {\n return Effect.void;\n }\n if (i < arr.length) {\n leftover = arr.slice(i);\n }\n return Cause.done();\n });\n },\n step: constVoid\n });\n }), Effect.forever({\n disableYield: true\n }), Pull.catchDone(() => Effect.succeed([out, leftover])));\n});\n/**\n * A sink that executes the provided effectful function for every item fed\n * to it.\n *\n * **Example** (Running effects for each item)\n *\n * ```ts import.meta.vitest\n * import { Effect, Sink, Stream } from \"effect\"\n *\n * const processed: Array<number> = []\n * const sink = Sink.forEach((item: number) => Effect.sync(() => processed.push(item)))\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromise(Stream.run(stream, sink))\n * processed // => [1, 2, 3]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const forEach = f => forEachArray(Effect.forEach(_ => f(_), {\n discard: true\n}));\n/**\n * A sink that executes the provided effectful function for every Chunk fed\n * to it.\n *\n * **Example** (Running effects for each chunk)\n *\n * ```ts import.meta.vitest\n * import { Effect, Sink, Stream } from \"effect\"\n *\n * const processed: Array<Array<number>> = []\n * const sink = Sink.forEachArray((chunk: ReadonlyArray<number>) => Effect.sync(() => processed.push([...chunk])))\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3, 4, 5)\n * await Effect.runPromise(Stream.run(stream, sink))\n * processed // => [[1, 2, 3, 4, 5]]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const forEachArray = f => fromTransform(upstream => upstream.pipe(Effect.flatMap(f), Effect.forever({\n disableYield: true\n}), Pull.catchDone(() => endVoid)));\n/**\n * Runs an effectful function for each input element while it returns `true`.\n *\n * **Details**\n *\n * The sink stops consuming input when the function returns `false` or when the\n * upstream stream ends, and completes with `void`.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const forEachWhile = f => forEachWhileArray(Effect.fnUntraced(function* (input) {\n for (let i = 0; i < input.length; i++) {\n const cont = yield* f(input[i]);\n if (!cont) return false;\n }\n return true;\n}));\n/**\n * Runs an effectful function for each non-empty input array while it returns\n * `true`.\n *\n * **Details**\n *\n * The sink stops consuming input when the function returns `false` or when the\n * upstream stream ends, and completes with `void`.\n *\n * @stability stable\n * @category constructors\n * @since 4.0.0\n */\nexport const forEachWhileArray = f => fromTransform(upstream => upstream.pipe(Effect.flatMap(f), Effect.flatMap(cont => cont ? Effect.void : Cause.done()), Effect.forever({\n disableYield: true\n}), Pull.catchDone(() => endVoid)));\n/**\n * Creates a sink produced from a scoped effect.\n *\n * **Example** (Unwrapping a sink effect)\n *\n * ```ts import.meta.vitest\n * import { Effect, Sink, Stream } from \"effect\"\n *\n * // Create a sink from an effect that produces a sink\n * const processed: Array<number> = []\n * const sinkEffect = Effect.succeed(\n * Sink.forEach((item: number) => Effect.sync(() => processed.push(item)))\n * )\n * const sink = Sink.unwrap(sinkEffect)\n *\n * // Use it with a stream\n * const stream = Stream.make(1, 2, 3)\n * await Effect.runPromise(Stream.run(stream, sink))\n * processed // => [1, 2, 3]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const unwrap = effect => fromChannel(Channel.unwrap(Effect.map(effect, toChannel)));\n/**\n * Runs a summary effect when the sink starts and again when it completes.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const summarized = /*#__PURE__*/dual(3, (self, summary, f) => fromTransform(Effect.fnUntraced(function* (upstream, scope) {\n const start = yield* summary;\n const [done, leftover] = yield* self.transform(upstream, scope);\n const end = yield* summary;\n return [[done, f(start, end)], leftover];\n})));\n/**\n * Returns the sink that executes this one and times its execution.\n *\n * @stability stable\n * @category mapping\n * @since 2.0.0\n */\nexport const withDuration = self => summarized(self, Clock.monotonicTimeNanos, (start, end) => Duration.nanos(end - start));\n/**\n * A sink that drains all input and returns the elapsed duration.\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const timed = /*#__PURE__*/map(/*#__PURE__*/withDuration(drain), ([, duration]) => duration);\n/**\n * Provides a `Context` to this sink.\n *\n * **Details**\n *\n * Services contained in the provided context are removed from the sink's\n * service requirements.\n *\n * @stability stable\n * @category providing services\n * @since 2.0.0\n */\nexport const provideContext = /*#__PURE__*/dual(2, (self, context) => fromTransform((upstream, scope) => self.transform(upstream, scope).pipe(Effect.provideContext(context))));\n/**\n * Provides a single service implementation to this sink.\n *\n * **Details**\n *\n * The service identified by `key` is removed from the sink's service\n * requirements.\n *\n * @stability stable\n * @category providing services\n * @since 4.0.0\n */\nexport const provideService = /*#__PURE__*/dual(3, (self, key, value) => fromTransform((upstream, scope) => self.transform(upstream, scope).pipe(Effect.provideService(key, value))));\n/**\n * Runs a fallback sink if this sink fails with a typed error.\n *\n * **Details**\n *\n * The fallback is built from the error and continues consuming from the same\n * upstream stream. If the upstream stream had already ended, the fallback sees\n * the upstream end instead.\n *\n * @stability stable\n * @category error handling\n * @since 2.0.0\n */\nexport const orElse = /*#__PURE__*/dual(2, (self, f) => fromTransform((upstream, scope) => {\n let upstreamDone = false;\n const pull = Effect.catchCause(upstream, cause => {\n upstreamDone = true;\n return Effect.failCause(cause);\n });\n return Effect.catch(self.transform(pull, scope), error => f(error).transform(Effect.suspend(() => {\n if (upstreamDone) {\n return Cause.done();\n }\n return upstream;\n }), scope));\n}));\n/**\n * Handles failures from this sink by inspecting the full `Cause`.\n *\n * **When to use**\n *\n * Use to recover from a sink failure based on the full `Cause` instead of only\n * the typed error value.\n *\n * **Details**\n *\n * When this sink fails, the handler effect is run and its success value\n * becomes the sink result. If the handler fails, the returned sink fails with\n * that error.\n *\n * @see {@link catch_ catch} for recovering from typed errors only\n * @see {@link orElse} for recovering by switching to another sink\n *\n * @stability stable\n * @category error handling\n * @since 4.0.0\n */\nexport const catchCause = /*#__PURE__*/dual(2, (self, f) => transformEffect(self, Effect.catchCause(cause =>\n// Upstream failures are not sink errors, so they bypass the handler.\nChannel.hasUpstreamFailure(cause) ? Effect.failCause(cause) : Effect.map(f(cause), a2 => [a2]))));\nconst catch_ = /*#__PURE__*/dual(2, (self, f) => transformEffect(self, Effect.catch(error => Effect.map(f(error), a2 => [a2]))));\nexport {\n/**\n * Handles typed errors from this sink with an effectful fallback value.\n *\n * **When to use**\n *\n * Use to recover from a typed sink failure by producing the replacement\n * result with an `Effect`.\n *\n * @see {@link catchCause} for recovering from the full failure cause\n * @see {@link orElse} for recovering by switching to another sink\n *\n * @stability stable\n * @category error handling\n * @since 4.0.0\n */\ncatch_ as catch };\n/**\n * Runs an effect after this sink completes, fails, or is interrupted.\n *\n * **Details**\n *\n * The effect receives the sink's `Exit` for the result value. The original\n * sink result and leftovers are preserved unless the finalizer itself fails.\n *\n * @stability stable\n * @category resource management\n * @since 4.0.0\n */\nexport const onExit = /*#__PURE__*/dual(2, (self, f) => transformEffect(self, Effect.onExit(exit =>\n// Upstream failures stop the sink like an interruption; they are not\n// sink errors.\nf(Exit.isFailure(exit) && Channel.hasUpstreamFailure(exit.cause) ? Exit.interrupt() : Exit.map(exit, ([a]) => a)))));\n/**\n * Runs a finalizer effect after this sink completes, fails, or is interrupted.\n *\n * **Details**\n *\n * The original sink result and leftovers are preserved unless the finalizer\n * itself fails.\n *\n * @stability stable\n * @category resource management\n * @since 2.0.0\n */\nexport const ensuring = /*#__PURE__*/dual(2, (self, effect) => onExit(self, () => effect));\n//# sourceMappingURL=Sink.js.map",
|
|
27
|
+
"import * as Context from \"../Context.js\";\nimport * as Duration from \"../Duration.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Exit from \"../Exit.js\";\nimport * as Fiber from \"../Fiber.js\";\nimport { identity } from \"../Function.js\";\nimport { pipeArguments } from \"../Pipeable.js\";\nimport * as Scope from \"../Scope.js\";\nconst TypeId = \"~effect/RcRef\";\nconst stateEmpty = {\n _tag: \"Empty\"\n};\nconst stateClosed = {\n _tag: \"Closed\"\n};\nconst variance = {\n _A: identity,\n _E: identity\n};\nclass RcRefImpl {\n [TypeId] = variance;\n pipe() {\n return pipeArguments(this, arguments);\n }\n state = stateEmpty;\n acquire;\n context;\n scope;\n idleTimeToLive;\n constructor(acquire, context, scope, idleTimeToLive) {\n this.acquire = acquire;\n this.context = context;\n this.scope = scope;\n this.idleTimeToLive = idleTimeToLive;\n }\n}\n/** @internal */\nexport const make = options => Effect.withFiber(fiber => {\n const context = fiber.context;\n const scope = Context.get(context, Scope.Scope);\n const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive !== undefined ? Duration.fromInputUnsafe(options.idleTimeToLive) : undefined);\n return Effect.as(Scope.addFinalizerExit(scope, () => {\n const state = ref.state;\n ref.state = stateClosed;\n if (state._tag === \"Acquired\") return Scope.close(state.scope, Exit.void);\n if (state._tag === \"Acquiring\") return Fiber.interrupt(state.fiber);\n return Effect.void;\n }), ref);\n});\nconst getState = (self, restore) => {\n switch (self.state._tag) {\n case \"Closed\":\n {\n return Effect.interrupt;\n }\n case \"Acquired\":\n {\n const state = self.state;\n state.refCount++;\n return state.fiber ? Effect.as(Fiber.interrupt(state.fiber), state) : Effect.succeed(state);\n }\n case \"Acquiring\":\n {\n const state = self.state;\n state.awaiters++;\n return awaitAcquiring(self, state, restore);\n }\n case \"Empty\":\n {\n // The caller that starts the acquisition counts as its first awaiter.\n const acquiring = {\n _tag: \"Acquiring\",\n fiber: undefined,\n awaiters: 1,\n acquired: undefined\n };\n self.state = acquiring;\n const scope = Scope.makeUnsafe();\n // Acquire on a detached fiber so the acquisition is shared by every\n // caller and only interrupted once all of them have been interrupted.\n const acquire = Effect.provideContext(self.acquire, Context.add(self.context, Scope.Scope, scope)).pipe(Effect.flatMap(value => {\n // The ref was closed, or the acquisition was abandoned.\n if (self.state !== acquiring) {\n return Effect.interrupt;\n }\n const state = {\n _tag: \"Acquired\",\n value,\n scope,\n fiber: undefined,\n // Every caller still waiting holds a reference.\n refCount: acquiring.awaiters,\n invalidated: false\n };\n self.state = state;\n acquiring.acquired = state;\n return Effect.succeed(state);\n }), Effect.onExit(exit => {\n if (Exit.isSuccess(exit)) return Effect.void;\n if (self.state === acquiring) self.state = stateEmpty;\n return Scope.close(scope, exit);\n }));\n acquiring.fiber = Effect.runForkWith(Fiber.getCurrent().context)(acquire);\n return awaitAcquiring(self, acquiring, restore);\n }\n }\n};\nconst awaitAcquiring = (self, acquiring, restore) => Effect.onExit(restore(Fiber.join(acquiring.fiber)), exit => {\n const acquired = acquiring.acquired;\n if (acquired !== undefined) {\n // The acquisition counted this caller as a reference, possibly before\n // its fiber exited. Release it if the caller was interrupted before it\n // could register its finalizer.\n return Exit.isFailure(exit) ? release(self, acquired) : Effect.void;\n }\n // Abandon the acquisition once every caller has left, unless it already\n // failed (a failed acquisition allocated no references).\n if (--acquiring.awaiters > 0 || self.state !== acquiring) return Effect.void;\n // Detach it first so new callers start a fresh acquisition instead of\n // joining one that is being interrupted.\n self.state = stateEmpty;\n return Fiber.interrupt(acquiring.fiber);\n});\n/** @internal */\nexport const get = self_ => {\n const self = self_;\n return Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.scope, scope => Effect.flatMap(getState(self, restore), state => Effect.as(Scope.addFinalizerExit(scope, () => release(self, state)), state.value))));\n};\nconst release = (self, state) => {\n state.refCount--;\n if (state.refCount > 0) {\n return Effect.void;\n }\n const idleTimeToLive = self.idleTimeToLive;\n if (idleTimeToLive === undefined || state.invalidated) {\n if (self.state === state) {\n self.state = stateEmpty;\n }\n return Scope.close(state.scope, Exit.void);\n } else if (!Duration.isFinite(idleTimeToLive)) {\n return Effect.void;\n }\n state.fiber = Effect.uninterruptibleMask(restore => Effect.flatMap(restore(Effect.sleep(idleTimeToLive)), () => {\n if (self.state === state && state.refCount === 0) {\n self.state = stateEmpty;\n return Effect.ignoreCause(Scope.close(state.scope, Exit.void), {\n log: \"Unhandled\",\n message: \"Unhandled error in RcRef finalizer\"\n });\n }\n return Effect.void;\n })).pipe(Effect.ensuring(Effect.sync(() => {\n state.fiber = undefined;\n })), Effect.runForkWith(self.context), Fiber.runIn(self.scope));\n return Effect.void;\n};\n/** @internal */\nexport const invalidate = self_ => {\n const self = self_;\n return Effect.uninterruptible(Effect.suspend(() => {\n if (self.state._tag !== \"Acquired\") {\n return Effect.void;\n }\n const state = self.state;\n self.state = stateEmpty;\n state.invalidated = true;\n if (state.refCount > 0) {\n return Effect.void;\n }\n state.fiber?.interruptUnsafe();\n return Scope.close(state.scope, Exit.void);\n }));\n};\n//# sourceMappingURL=rcRef.js.map",
|
|
28
|
+
"import * as internal from \"./internal/rcRef.js\";\nconst TypeId = \"~effect/RcRef\";\n/**\n * Creates an `RcRef` from an acquire effect.\n *\n * **When to use**\n *\n * Use to create a lazily acquired, reference-counted resource from an acquire\n * effect.\n *\n * **Details**\n *\n * The resource is acquired lazily on the first `get` and shared by subsequent\n * gets while it remains cached. Each `get` adds a reference to the current\n * `Scope`. When the last reference is released, the resource is closed\n * immediately by default, or after `idleTimeToLive` when that option is\n * provided.\n *\n * **Example** (Creating a reference-counted resource)\n *\n * ```ts import.meta.vitest\n * import { Effect, RcRef } from \"effect\"\n *\n * const events: Array<string> = []\n *\n * const program = Effect.gen(function*() {\n * const ref = yield* RcRef.make({\n * acquire: Effect.acquireRelease(\n * Effect.succeed(\"foo\"),\n * () => Effect.sync(() => events.push(\"released foo\"))\n * )\n * })\n *\n * // will only acquire the resource once, and release it\n * // when the scope is closed\n * yield* RcRef.get(ref).pipe(\n * Effect.andThen(RcRef.get(ref)),\n * Effect.scoped\n * )\n * })\n *\n * await Effect.runPromise(Effect.scoped(program))\n * events // => [\"released foo\"]\n * ```\n *\n * @stability stable\n * @category constructors\n * @since 3.5.0\n */\nexport const make = internal.make;\n/**\n * Gets the value from an `RcRef`, acquiring it first if needed.\n *\n * **When to use**\n *\n * Use to borrow the current resource within a `Scope`, acquiring it first if\n * necessary.\n *\n * **Details**\n *\n * The reference count is incremented for the current `Scope`, and a release\n * finalizer is added to that scope. When the current scope closes, the\n * reference is released; the resource is closed when the final reference is\n * released, subject to any configured idle time-to-live.\n *\n * **Example** (Sharing one acquired value)\n *\n * ```ts import.meta.vitest\n * import { Effect, RcRef } from \"effect\"\n *\n * const events: Array<string> = []\n *\n * const program = Effect.gen(function*() {\n * // Create an RcRef with a resource\n * const ref = yield* RcRef.make({\n * acquire: Effect.acquireRelease(\n * Effect.succeed(\"shared resource\"),\n * (resource) => Effect.sync(() => events.push(`released ${resource}`))\n * )\n * })\n *\n * // Get the value from the RcRef\n * const value1 = yield* RcRef.get(ref)\n * const value2 = yield* RcRef.get(ref)\n *\n * return [value1 === value2, events] as const\n * })\n *\n * await Effect.runPromise(Effect.scoped(program)) // => [true, [\"released shared resource\"]]\n * ```\n *\n * @stability stable\n * @category combinators\n * @since 3.5.0\n */\nexport const get = internal.get;\n/**\n * Invalidates the currently cached resource, if one has been acquired.\n *\n * **When to use**\n *\n * Use to force future `RcRef.get` calls to acquire a fresh resource when the\n * currently cached resource should no longer be reused.\n *\n * **Details**\n *\n * After invalidation, the next `get` acquires a fresh resource.\n *\n * **Gotchas**\n *\n * Invalidation does not revoke resources already borrowed by active scopes;\n * those remain usable until their scopes close.\n *\n * @see {@link get} for acquiring the current cached resource or the fresh resource after invalidation\n *\n * @stability stable\n * @category combinators\n * @since 3.19.6\n */\nexport const invalidate = internal.invalidate;\n//# sourceMappingURL=RcRef.js.map",
|
|
29
|
+
"/**\n * Defines the portable file system service for Effect programs.\n *\n * `FileSystem` is the boundary between Effect code and the host file system.\n * Platform packages provide concrete layers, while this module defines the\n * operations for reading, writing, inspecting, streaming, and watching files.\n * Operations return `Effect`, `Stream`, or `Sink` values and fail with\n * `PlatformError`. The module also includes file handles, open flags, watch\n * events, and the watch backend service.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Arr from \"./Array.js\";\nimport * as ByteSize from \"./ByteSize.js\";\nimport * as Cause from \"./Cause.js\";\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport { pipe } from \"./Function.js\";\nimport * as Glob from \"./internal/glob.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as Option from \"./Option.js\";\nimport { badArgument, systemError } from \"./PlatformError.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Sink from \"./Sink.js\";\nimport * as Stream from \"./Stream.js\";\nconst TypeId = \"~effect/FileSystem\";\n/**\n * Service tag for platform file-system operations.\n *\n * **When to use**\n *\n * Use to access or provide operations for files, directories, permissions,\n * streams, and sinks through the Effect context.\n *\n * **Details**\n *\n * This key is used to provide and access the FileSystem service in the Effect context.\n *\n * **Example** (Accessing and providing FileSystem)\n *\n * ```ts import.meta.vitest\n * import { Effect, FileSystem } from \"effect\"\n *\n * const customFs = FileSystem.makeNoop({\n * exists: () => Effect.succeed(true),\n * readFileString: () => Effect.succeed(\"contents\")\n * })\n *\n * // Access the FileSystem service\n * const program = Effect.gen(function*() {\n * const fs = yield* FileSystem.FileSystem\n *\n * const exists = yield* fs.exists(\"./data.txt\")\n * return exists ? yield* fs.readFileString(\"./data.txt\") : undefined\n * })\n *\n * const withCustomFs = Effect.provideService(\n * program,\n * FileSystem.FileSystem,\n * customFs\n * )\n * Effect.runSync(withCustomFs) // => \"contents\"\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport const FileSystem = /*#__PURE__*/Context.Service(\"effect/FileSystem\");\n/**\n * Creates a FileSystem implementation from a partial implementation.\n *\n * **When to use**\n *\n * Use to build a concrete `FileSystem` service from platform-specific core\n * operations while deriving the convenience methods that can be implemented\n * from them.\n *\n * **Details**\n *\n * This function takes a partial FileSystem implementation and automatically provides\n * default implementations for `exists`, `glob`, `readFileString`, `stream`, `sink`,\n * and `writeFileString` methods based on the provided core methods. `glob` walks\n * the tree with `readDirectoryEntries`, using `stat` and `readLink` for entries\n * whose type is `\"Unknown\"`.\n *\n * @see {@link makeNoop} for a testing stub that accepts method overrides without requiring a complete implementation\n * @see {@link layerNoop} for providing a no-op `FileSystem` as a `Layer` in tests\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = impl => FileSystem.of({\n ...impl,\n [TypeId]: TypeId,\n glob: Glob.make(impl),\n exists: path => pipe(impl.access(path), Effect.as(true), Effect.catchTag(\"PlatformError\", e => e.reason._tag === \"NotFound\" ? Effect.succeed(false) : Effect.fail(e))),\n readFileString: (path, encoding) => Effect.flatMap(impl.readFile(path), _ => Effect.try({\n try: () => new TextDecoder(encoding).decode(_),\n catch: cause => badArgument({\n module: \"FileSystem\",\n method: \"readFileString\",\n description: \"invalid encoding\",\n cause\n })\n })),\n stream: Effect.fnUntraced(function* (path, options) {\n const file = yield* impl.open(path, {\n flag: \"r\"\n });\n const offset = options?.offset === undefined ? undefined : ByteSize.fromInputUnsafe(options.offset);\n if (offset) {\n yield* file.seek(offset, \"start\");\n }\n const bytesToRead = options?.bytesToRead === undefined ? undefined : ByteSize.fromInputUnsafe(options.bytesToRead);\n let totalBytesRead = BigInt(0);\n // Validate chunk sizes even for zero-byte reads.\n const chunkSize = Number(BigInt(options?.chunkSize ?? 64 * 1024));\n const readChunk = file.readAlloc(chunkSize);\n return Stream.fromPull(Effect.succeed(Effect.flatMap(Effect.suspend(() => {\n if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) {\n return Cause.done();\n }\n return bytesToRead !== undefined && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk;\n }), Option.match({\n onNone: () => Cause.done(),\n onSome: buf => {\n totalBytesRead += BigInt(buf.length);\n return Effect.succeed(Arr.of(buf));\n }\n }))));\n }, Stream.unwrap),\n sink: (path, options) => pipe(impl.open(path, {\n ...options,\n flag: options?.flag ?? \"w\"\n }), Effect.map(file => Sink.forEach(_ => file.writeAll(_))), Sink.unwrap),\n writeFileString: (path, data, options) => Effect.flatMap(Effect.try({\n try: () => new TextEncoder().encode(data),\n catch: cause => badArgument({\n module: \"FileSystem\",\n method: \"writeFileString\",\n description: \"could not encode string\",\n cause\n })\n }), _ => impl.writeFile(path, _, options))\n});\nconst notFound = (method, path) => systemError({\n module: \"FileSystem\",\n method,\n _tag: \"NotFound\",\n description: \"No such file or directory\",\n pathOrDescriptor: path\n});\n/**\n * Creates a stub `FileSystem` implementation for tests.\n *\n * **Details**\n *\n * By default, `exists` returns `false`, `remove` succeeds, many file operations\n * fail with `PlatformError` `NotFound`, and temporary-directory/file operations\n * die as not implemented. Pass method overrides to provide the behavior needed\n * by a specific test without touching the real file system.\n *\n * **Example** (Creating a no-op FileSystem)\n *\n * ```ts import.meta.vitest\n * import { Effect, FileSystem, PlatformError } from \"effect\"\n *\n * // Create a test filesystem that only allows reading specific files\n * const testFs = FileSystem.makeNoop({\n * readFileString: (path) => {\n * if (path === \"test-config.json\") {\n * return Effect.succeed(\"{\\\"test\\\": true}\")\n * }\n * return Effect.fail(\n * PlatformError.systemError({\n * _tag: \"NotFound\",\n * module: \"FileSystem\",\n * method: \"readFileString\",\n * description: \"File not found\",\n * pathOrDescriptor: path\n * })\n * )\n * },\n * exists: (path) => Effect.succeed(path === \"test-config.json\")\n * })\n *\n * // Use in tests\n * const program = Effect.gen(function*() {\n * const content = yield* testFs.readFileString(\"test-config.json\")\n * return content\n * })\n *\n * // Test with the no-op filesystem\n * const testProgram = Effect.provideService(\n * program,\n * FileSystem.FileSystem,\n * testFs\n * )\n * Effect.runSync(testProgram) // => \"{\\\"test\\\": true}\"\n * ```\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const makeNoop = fileSystem => FileSystem.of({\n [TypeId]: TypeId,\n access(path) {\n return Effect.fail(notFound(\"access\", path));\n },\n chmod(path) {\n return Effect.fail(notFound(\"chmod\", path));\n },\n chown(path) {\n return Effect.fail(notFound(\"chown\", path));\n },\n copy(path) {\n return Effect.fail(notFound(\"copy\", path));\n },\n copyFile(path) {\n return Effect.fail(notFound(\"copyFile\", path));\n },\n glob(pattern) {\n return Effect.fail(notFound(\"glob\", pattern));\n },\n exists() {\n return Effect.succeed(false);\n },\n link(path) {\n return Effect.fail(notFound(\"link\", path));\n },\n lstat(path) {\n return Effect.fail(notFound(\"lstat\", path));\n },\n makeDirectory() {\n return Effect.die(\"not implemented\");\n },\n makeTempDirectory() {\n return Effect.die(\"not implemented\");\n },\n makeTempDirectoryScoped() {\n return Effect.die(\"not implemented\");\n },\n makeTempFile() {\n return Effect.die(\"not implemented\");\n },\n makeTempFileScoped() {\n return Effect.die(\"not implemented\");\n },\n open(path) {\n return Effect.fail(notFound(\"open\", path));\n },\n readDirectory(path) {\n return Effect.fail(notFound(\"readDirectory\", path));\n },\n readDirectoryEntries(path) {\n return Effect.fail(notFound(\"readDirectoryEntries\", path));\n },\n readFile(path) {\n return Effect.fail(notFound(\"readFile\", path));\n },\n readFileString(path) {\n return Effect.fail(notFound(\"readFileString\", path));\n },\n readLink(path) {\n return Effect.fail(notFound(\"readLink\", path));\n },\n realPath(path) {\n return Effect.fail(notFound(\"realPath\", path));\n },\n remove() {\n return Effect.void;\n },\n rename(oldPath) {\n return Effect.fail(notFound(\"rename\", oldPath));\n },\n sink(path) {\n return Sink.fail(notFound(\"sink\", path));\n },\n stat(path) {\n return Effect.fail(notFound(\"stat\", path));\n },\n stream(path) {\n return Stream.fail(notFound(\"stream\", path));\n },\n symlink(fromPath) {\n return Effect.fail(notFound(\"symlink\", fromPath));\n },\n truncate(path) {\n return Effect.fail(notFound(\"truncate\", path));\n },\n utimes(path) {\n return Effect.fail(notFound(\"utimes\", path));\n },\n watch(path) {\n return Stream.fail(notFound(\"watch\", path));\n },\n writeFile(path) {\n return Effect.fail(notFound(\"writeFile\", path));\n },\n writeFileString(path) {\n return Effect.fail(notFound(\"writeFileString\", path));\n },\n ...fileSystem\n});\n/**\n * Creates a Layer that provides a no-op FileSystem implementation for testing.\n *\n * **Details**\n *\n * This is a convenience function that wraps `makeNoop` in a Layer, making it easy\n * to provide the test filesystem to your Effect programs.\n *\n * **Example** (Providing a no-op FileSystem layer)\n *\n * ```ts import.meta.vitest\n * import { Effect, FileSystem } from \"effect\"\n *\n * // Create a test layer with specific behaviors\n * const testLayer = FileSystem.layerNoop({\n * readFileString: (path) => Effect.succeed(\"mocked content\"),\n * exists: () => Effect.succeed(true)\n * })\n *\n * const program = Effect.gen(function*() {\n * const fs = yield* FileSystem.FileSystem\n * const content = yield* fs.readFileString(\"any-file.txt\")\n * return content\n * })\n *\n * // Provide the test layer\n * const testProgram = Effect.provide(program, testLayer)\n * Effect.runSync(testProgram) // => \"mocked content\"\n * ```\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerNoop = fileSystem => Layer.succeed(FileSystem)(makeNoop(fileSystem));\n/**\n * Runtime type identifier attached to `FileSystem.File` handles and used by\n * `isFile` to recognize them.\n *\n * **Details**\n *\n * This marker is part of the runtime representation of file handles. Prefer\n * `isFile` when narrowing unknown values.\n *\n * @see {@link File} for the open file handle shape that carries this marker\n * @see {@link isFile} for the public guard that checks this marker\n *\n * @stability unstable\n * @category type IDs\n * @since 4.0.0\n */\nexport const FileTypeId = \"~effect/FileSystem/File\";\n/**\n * Returns `true` if a value is a `File` handle by checking for the\n * `FileTypeId` marker.\n *\n * **When to use**\n *\n * Use when accepting an unknown value and you need to narrow it to a `File`\n * before calling file-handle operations.\n *\n * **Details**\n *\n * This is a structural marker check. It does not validate the marker value or\n * the shape of the file handle.\n *\n * @see {@link File} for the file-handle interface narrowed by this guard\n * @see {@link FileTypeId} for the runtime marker checked by this guard\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isFile = u => hasProperty(u, FileTypeId);\n/**\n * Service key for file system watch backend implementations.\n *\n * **Details**\n *\n * This service provides the low-level file watching capabilities that can be\n * implemented differently on various platforms (e.g., inotify on Linux,\n * FSEvents on macOS, etc.).\n *\n * **Example** (Providing a custom watch backend)\n *\n * ```ts import.meta.vitest\n * import { Effect, FileSystem, Option, Stream } from \"effect\"\n *\n * // Custom watch backend implementation\n * const customWatchBackend = {\n * register: (path: string, stat: FileSystem.File.Info) => {\n * // Implementation would depend on platform\n * return Option.some(Stream.empty) // Placeholder implementation\n * }\n * }\n *\n * const program = Effect.gen(function*() {\n * const backend = yield* FileSystem.WatchBackend\n * return Option.isSome(\n * backend.register(\"./directory\", { type: \"Directory\" } as FileSystem.File.Info)\n * )\n * })\n *\n * const withCustomBackend = Effect.provideService(\n * program,\n * FileSystem.WatchBackend,\n * customWatchBackend\n * )\n * Effect.runSync(withCustomBackend) // => true\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class WatchBackend extends /*#__PURE__*/Context.Service()(\"effect/FileSystem/WatchBackend\") {}\n//# sourceMappingURL=FileSystem.js.map",
|
|
30
|
+
"/**\n * Provides path operations through the Effect environment.\n *\n * The `Path` service works with file system paths without tying code to one\n * concrete platform module. It exposes common operations such as joining,\n * normalizing, parsing, formatting, resolving, and converting paths to or from\n * file URLs. This module includes the service interface, parsed path type,\n * service tag, runtime marker, and built-in POSIX path layer.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport { identity } from \"./Function.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as Option from \"./Option.js\";\nimport { BadArgument } from \"./PlatformError.js\";\n/**\n * Runtime type identifier used to mark implementations of the `Path` service.\n *\n * **Details**\n *\n * The marker is the exact string stored on `Path` service implementations.\n * Most code should depend on the `Path` service instead of inspecting this\n * value directly.\n *\n * @see {@link layer} for the built-in POSIX `Path` service layer\n *\n * @stability unstable\n * @category type IDs\n * @since 4.0.0\n */\nexport const TypeId = \"~effect/Path\";\n/**\n * Service tag for accessing the current `Path` implementation.\n *\n * **When to use**\n *\n * Use when you need path operations supplied by an effect's environment.\n *\n * **Example** (Providing a custom Path service)\n *\n * ```ts import.meta.vitest\n * import { Effect, Layer, Path } from \"effect\"\n *\n * // Create a custom path implementation\n * const customPath = Path.make({\n * sep: \"/\",\n * basename: (path: string, suffix?: string) => {\n * const base = path.split(\"/\").pop() || \"\"\n * return suffix && base.endsWith(suffix)\n * ? base.slice(0, -suffix.length)\n * : base\n * },\n * dirname: (path: string) => path.split(\"/\").slice(0, -1).join(\"/\") || \"/\",\n * extname: (path: string) => {\n * const match = path.match(/\\.[^.]*$/)\n * return match ? match[0] : \"\"\n * },\n * format: (pathObject) => {\n * const dir = pathObject.dir || \"\"\n * const name = pathObject.name || \"\"\n * const ext = pathObject.ext || \"\"\n * return dir ? `${dir}/${name}${ext}` : `${name}${ext}`\n * },\n * fromFileUrl: (url: URL) => Effect.succeed(url.pathname),\n * isAbsolute: (path: string) => path.startsWith(\"/\"),\n * join: (...paths: ReadonlyArray<string>) => paths.join(\"/\"),\n * normalize: (path: string) => path.replace(/\\/+/g, \"/\"),\n * parse: (path: string) => ({\n * root: path.startsWith(\"/\") ? \"/\" : \"\",\n * dir: path.split(\"/\").slice(0, -1).join(\"/\") || \"/\",\n * base: path.split(\"/\").pop() || \"\",\n * ext: path.match(/\\.[^.]*$/)?.[0] || \"\",\n * name: path.split(\"/\").pop()?.replace(/\\.[^.]*$/, \"\") || \"\"\n * }),\n * relative: (from: string, to: string) => to.replace(from, \"\"),\n * resolve: (...pathSegments: ReadonlyArray<string>) => pathSegments.join(\"/\"),\n * toFileUrl: (path: string) => Effect.succeed(new URL(`file://${path}`)),\n * toNamespacedPath: (path: string) => path\n * })\n *\n * // Provide the path service\n * const customPathLayer = Layer.succeed(Path.Path)(customPath)\n *\n * const program = Effect.gen(function*() {\n * const path = yield* Path.Path\n * return path.join(\"home\", \"user\", \"file.txt\")\n * })\n *\n * // Run with custom path implementation\n * Effect.runSync(Effect.provide(program, customPathLayer)) // => \"home/user/file.txt\"\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport const Path = /*#__PURE__*/Context.Service(\"effect/Path\");\n/**\n * Creates a `Path` service from platform path operations.\n *\n * **When to use**\n *\n * Use to build a `Path` implementation, such as a platform layer or a test\n * double, without implementing the operations that can be derived from the\n * others.\n *\n * **Details**\n *\n * Adds the `Path` type marker and derives `resolveWithin` from the provided\n * `parse`, `resolve`, `relative`, `isAbsolute`, and `sep`, so containment\n * follows the same platform rules as those operations.\n *\n * @see {@link layer} for the built-in POSIX `Path` service layer\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = impl => Path.of({\n ...impl,\n [TypeId]: TypeId,\n resolveWithin(root, input) {\n if (impl.parse(input).root !== \"\") return Option.none();\n const base = impl.resolve(root);\n const candidate = impl.resolve(base, input);\n const relative = impl.relative(base, candidate);\n return relative === \"..\" || relative.startsWith(`..${impl.sep}`) || impl.isAbsolute(relative) ? Option.none() : Option.some(candidate);\n }\n});\n/**\n * The following functions are adapted from the Node.js source code:\n * https://github.com/nodejs/node/blob/main/lib/internal/url.js\n *\n * The following license applies to these functions:\n * - MIT\n */\n// Resolves . and .. elements in a path with directory names\nfunction normalizeStringPosix(path, allowAboveRoot) {\n let res = \"\";\n let lastSegmentLength = 0;\n let lastSlash = -1;\n let dots = 0;\n let code;\n for (let i = 0; i <= path.length; ++i) {\n if (i < path.length) {\n code = path.charCodeAt(i);\n } else if (code === 47 /*/*/) {\n break;\n } else {\n code = 47; /*/*/\n }\n if (code === 47 /*/*/) {\n if (lastSlash === i - 1 || dots === 1) {\n // NOOP\n } else if (lastSlash !== i - 1 && dots === 2) {\n if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {\n if (res.length > 2) {\n const lastSlashIndex = res.lastIndexOf(\"/\");\n if (lastSlashIndex !== res.length - 1) {\n if (lastSlashIndex === -1) {\n res = \"\";\n lastSegmentLength = 0;\n } else {\n res = res.slice(0, lastSlashIndex);\n lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\");\n }\n lastSlash = i;\n dots = 0;\n continue;\n }\n } else if (res.length === 2 || res.length === 1) {\n res = \"\";\n lastSegmentLength = 0;\n lastSlash = i;\n dots = 0;\n continue;\n }\n }\n if (allowAboveRoot) {\n if (res.length > 0) {\n res += \"/..\";\n } else {\n res = \"..\";\n }\n lastSegmentLength = 2;\n }\n } else {\n if (res.length > 0) {\n res += \"/\" + path.slice(lastSlash + 1, i);\n } else {\n res = path.slice(lastSlash + 1, i);\n }\n lastSegmentLength = i - lastSlash - 1;\n }\n lastSlash = i;\n dots = 0;\n } else if (code === 46 /*.*/ && dots !== -1) {\n ++dots;\n } else {\n dots = -1;\n }\n }\n return res;\n}\nfunction formatExt(ext) {\n if (!ext) return \"\";\n return ext.startsWith(\".\") ? ext : `.${ext}`;\n}\nfunction _format(sep, pathObject) {\n const dir = pathObject.dir || pathObject.root;\n const base = pathObject.base || (pathObject.name || \"\") + formatExt(pathObject.ext);\n if (!dir) {\n return base;\n }\n if (dir === pathObject.root) {\n return dir + base;\n }\n return dir + sep + base;\n}\nfunction fromFileUrl(url) {\n if (url.protocol !== \"file:\") {\n return Effect.fail(new BadArgument({\n module: \"Path\",\n method: \"fromFileUrl\",\n description: \"URL must be of scheme file\"\n }));\n } else if (url.hostname !== \"\") {\n return Effect.fail(new BadArgument({\n module: \"Path\",\n method: \"fromFileUrl\",\n description: \"Invalid file URL host\"\n }));\n }\n const pathname = url.pathname;\n for (let n = 0; n < pathname.length; n++) {\n if (pathname[n] === \"%\") {\n const third = pathname.codePointAt(n + 2) | 0x20;\n if (pathname[n + 1] === \"2\" && third === 102) {\n return Effect.fail(new BadArgument({\n module: \"Path\",\n method: \"fromFileUrl\",\n description: \"must not include encoded / characters\"\n }));\n }\n }\n }\n return Effect.try({\n try: () => decodeURIComponent(pathname),\n catch: cause => new BadArgument({\n module: \"Path\",\n method: \"fromFileUrl\",\n cause\n })\n });\n}\nconst resolve = function resolve() {\n let resolvedPath = \"\";\n let resolvedAbsolute = false;\n let cwd = undefined;\n for (let i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n let path;\n if (i >= 0) {\n path = arguments[i];\n } else {\n const process = globalThis.process;\n if (cwd === undefined && \"process\" in globalThis && typeof process === \"object\" && process !== null && typeof process.cwd === \"function\") {\n cwd = process.cwd();\n }\n path = cwd;\n }\n // Skip empty entries\n if (path.length === 0) {\n continue;\n }\n resolvedPath = path + \"/\" + resolvedPath;\n resolvedAbsolute = path.charCodeAt(0) === 47; /*/*/\n }\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n // Normalize the path\n resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);\n if (resolvedAbsolute) {\n if (resolvedPath.length > 0) {\n return \"/\" + resolvedPath;\n } else {\n return \"/\";\n }\n } else if (resolvedPath.length > 0) {\n return resolvedPath;\n } else {\n return \".\";\n }\n};\nconst CHAR_FORWARD_SLASH = 47;\nfunction toFileUrl(filepath) {\n const outURL = new URL(\"file://\");\n let resolved = resolve(filepath);\n // path.resolve strips trailing slashes so we must add them back\n const filePathLast = filepath.charCodeAt(filepath.length - 1);\n if (filePathLast === CHAR_FORWARD_SLASH && resolved[resolved.length - 1] !== \"/\") {\n resolved += \"/\";\n }\n outURL.pathname = encodePathChars(resolved);\n return Effect.succeed(outURL);\n}\nconst percentRegExp = /%/g;\nconst backslashRegExp = /\\\\/g;\nconst newlineRegExp = /\\n/g;\nconst carriageReturnRegExp = /\\r/g;\nconst tabRegExp = /\\t/g;\nfunction encodePathChars(filepath) {\n if (filepath.includes(\"%\")) {\n filepath = filepath.replace(percentRegExp, \"%25\");\n }\n if (filepath.includes(\"\\\\\")) {\n filepath = filepath.replace(backslashRegExp, \"%5C\");\n }\n if (filepath.includes(\"\\n\")) {\n filepath = filepath.replace(newlineRegExp, \"%0A\");\n }\n if (filepath.includes(\"\\r\")) {\n filepath = filepath.replace(carriageReturnRegExp, \"%0D\");\n }\n if (filepath.includes(\"\\t\")) {\n filepath = filepath.replace(tabRegExp, \"%09\");\n }\n return filepath;\n}\nconst posixImpl = /*#__PURE__*/make({\n resolve,\n normalize(path) {\n if (path.length === 0) return \".\";\n const isAbsolute = path.charCodeAt(0) === 47; /*/*/\n const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /*/*/\n // Normalize the path\n path = normalizeStringPosix(path, !isAbsolute);\n if (path.length === 0 && !isAbsolute) path = \".\";\n if (path.length > 0 && trailingSeparator) path += \"/\";\n if (isAbsolute) return \"/\" + path;\n return path;\n },\n isAbsolute(path) {\n return path.length > 0 && path.charCodeAt(0) === 47; /*/*/\n },\n join() {\n if (arguments.length === 0) {\n return \".\";\n }\n let joined;\n for (let i = 0; i < arguments.length; ++i) {\n const arg = arguments[i];\n if (arg.length > 0) {\n if (joined === undefined) {\n joined = arg;\n } else {\n joined += \"/\" + arg;\n }\n }\n }\n if (joined === undefined) {\n return \".\";\n }\n return posixImpl.normalize(joined);\n },\n relative(from, to) {\n if (from === to) return \"\";\n from = posixImpl.resolve(from);\n to = posixImpl.resolve(to);\n if (from === to) return \"\";\n // Trim any leading backslashes\n let fromStart = 1;\n for (; fromStart < from.length; ++fromStart) {\n if (from.charCodeAt(fromStart) !== 47 /*/*/) {\n break;\n }\n }\n const fromEnd = from.length;\n const fromLen = fromEnd - fromStart;\n // Trim any leading backslashes\n let toStart = 1;\n for (; toStart < to.length; ++toStart) {\n if (to.charCodeAt(toStart) !== 47 /*/*/) {\n break;\n }\n }\n const toEnd = to.length;\n const toLen = toEnd - toStart;\n // Compare paths to find the longest common path from root\n const length = fromLen < toLen ? fromLen : toLen;\n let lastCommonSep = -1;\n let i = 0;\n for (; i <= length; ++i) {\n if (i === length) {\n if (toLen > length) {\n if (to.charCodeAt(toStart + i) === 47 /*/*/) {\n // We get here if `from` is the exact base path for `to`.\n // For example: from='/foo/bar'; to='/foo/bar/baz'\n return to.slice(toStart + i + 1);\n } else if (i === 0) {\n // We get here if `from` is the root\n // For example: from='/'; to='/foo'\n return to.slice(toStart + i);\n }\n } else if (fromLen > length) {\n if (from.charCodeAt(fromStart + i) === 47 /*/*/) {\n // We get here if `to` is the exact base path for `from`.\n // For example: from='/foo/bar/baz'; to='/foo/bar'\n lastCommonSep = i;\n } else if (i === 0) {\n // We get here if `to` is the root.\n // For example: from='/foo'; to='/'\n lastCommonSep = 0;\n }\n }\n break;\n }\n const fromCode = from.charCodeAt(fromStart + i);\n const toCode = to.charCodeAt(toStart + i);\n if (fromCode !== toCode) {\n break;\n } else if (fromCode === 47 /*/*/) {\n lastCommonSep = i;\n }\n }\n let out = \"\";\n // Generate the relative path based on the path difference between `to`\n // and `from`\n for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {\n if (out.length === 0) {\n out += \"..\";\n } else {\n out += \"/..\";\n }\n }\n }\n // Lastly, append the rest of the destination (`to`) path that comes after\n // the common path parts\n if (out.length > 0) {\n return out + to.slice(toStart + lastCommonSep);\n } else {\n toStart += lastCommonSep;\n if (to.charCodeAt(toStart) === 47 /*/*/) {\n ++toStart;\n }\n return to.slice(toStart);\n }\n },\n dirname(path) {\n if (path.length === 0) return \".\";\n let code = path.charCodeAt(0);\n const hasRoot = code === 47; /*/*/\n let end = -1;\n let matchedSlash = true;\n for (let i = path.length - 1; i >= 1; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n if (!matchedSlash) {\n end = i;\n break;\n }\n } else {\n // We saw the first non-path separator\n matchedSlash = false;\n }\n }\n if (end === -1) return hasRoot ? \"/\" : \".\";\n if (hasRoot && end === 1) return \"//\";\n return path.slice(0, end);\n },\n basename(path, ext) {\n let start = 0;\n let end = -1;\n let matchedSlash = true;\n let i;\n if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {\n if (ext.length === path.length && ext === path) return \"\";\n let extIdx = ext.length - 1;\n let firstNonSlashEnd = -1;\n for (i = path.length - 1; i >= 0; --i) {\n const code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else {\n if (firstNonSlashEnd === -1) {\n // We saw the first non-path separator, remember this index in case\n // we need it if the extension ends up not matching\n matchedSlash = false;\n firstNonSlashEnd = i + 1;\n }\n if (extIdx >= 0) {\n // Try to match the explicit extension\n if (code === ext.charCodeAt(extIdx)) {\n if (--extIdx === -1) {\n // We matched the extension, so mark this as the end of our path\n // component\n end = i;\n }\n } else {\n // Extension does not match, so our result is the entire path\n // component\n extIdx = -1;\n end = firstNonSlashEnd;\n }\n }\n }\n }\n if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;\n return path.slice(start, end);\n } else {\n for (i = path.length - 1; i >= 0; --i) {\n if (path.charCodeAt(i) === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n start = i + 1;\n break;\n }\n } else if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // path component\n matchedSlash = false;\n end = i + 1;\n }\n }\n if (end === -1) return \"\";\n return path.slice(start, end);\n }\n },\n extname(path) {\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n for (let i = path.length - 1; i >= 0; --i) {\n const code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) {\n startDot = i;\n } else if (preDotState !== 1) {\n preDotState = 1;\n }\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n return \"\";\n }\n return path.slice(startDot, end);\n },\n format: function format(pathObject) {\n if (pathObject === null || typeof pathObject !== \"object\") {\n throw new TypeError(\"The \\\"pathObject\\\" argument must be of type Object. Received type \" + typeof pathObject);\n }\n return _format(\"/\", pathObject);\n },\n parse(path) {\n const ret = {\n root: \"\",\n dir: \"\",\n base: \"\",\n ext: \"\",\n name: \"\"\n };\n if (path.length === 0) return ret;\n let code = path.charCodeAt(0);\n const isAbsolute = code === 47; /*/*/\n let start;\n if (isAbsolute) {\n ret.root = \"/\";\n start = 1;\n } else {\n start = 0;\n }\n let startDot = -1;\n let startPart = 0;\n let end = -1;\n let matchedSlash = true;\n let i = path.length - 1;\n // Track the state of characters (if any) we see before our first dot and\n // after any path separator we find\n let preDotState = 0;\n // Get non-dir info\n for (; i >= start; --i) {\n code = path.charCodeAt(i);\n if (code === 47 /*/*/) {\n // If we reached a path separator that was not part of a set of path\n // separators at the end of the string, stop now\n if (!matchedSlash) {\n startPart = i + 1;\n break;\n }\n continue;\n }\n if (end === -1) {\n // We saw the first non-path separator, mark this as the end of our\n // extension\n matchedSlash = false;\n end = i + 1;\n }\n if (code === 46 /*.*/) {\n // If this is our first dot, mark it as the start of our extension\n if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;\n } else if (startDot !== -1) {\n // We saw a non-dot and non-path separator before our dot, so we should\n // have a good chance at having a non-empty extension\n preDotState = -1;\n }\n }\n if (startDot === -1 || end === -1 ||\n // We saw a non-dot character immediately before the dot\n preDotState === 0 ||\n // The (right-most) trimmed path component is exactly '..'\n preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {\n if (end !== -1) {\n if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);\n }\n } else {\n if (startPart === 0 && isAbsolute) {\n ret.name = path.slice(1, startDot);\n ret.base = path.slice(1, end);\n } else {\n ret.name = path.slice(startPart, startDot);\n ret.base = path.slice(startPart, end);\n }\n ret.ext = path.slice(startDot, end);\n }\n if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = \"/\";\n return ret;\n },\n sep: \"/\",\n fromFileUrl,\n toFileUrl,\n toNamespacedPath: identity\n});\n/**\n * Layer that provides the built-in POSIX `Path` implementation.\n *\n * **When to use**\n *\n * Use when you need an effect that requires the `Path` service to run with the\n * built-in POSIX path implementation.\n *\n * **Details**\n *\n * The layer provides a static service whose separator is `/` and whose\n * operations use POSIX path semantics.\n *\n * @see {@link Path} for accessing the `Path` service from an effect\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.succeed(Path)(posixImpl);\n//# sourceMappingURL=Path.js.map",
|
|
31
|
+
"/// <reference lib=\"esnext.disposable\" preserve=\"true\" />\n/**\n * Runs many effects against services built once from a `Layer`.\n *\n * A `ManagedRuntime` builds the services from a layer, keeps those services\n * available for repeated effect runs, and releases acquired resources when it\n * is disposed. This module includes the runtime type, a constructor, a guard,\n * and runners for connecting Effect programs to JavaScript entry points such as\n * promises, callbacks, and synchronous code.\n *\n * @stability stable\n * @since 2.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Deferred from \"./Deferred.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Exit from \"./Exit.js\";\nimport * as Fiber from \"./Fiber.js\";\nimport { fiberEnterUninterruptibleUnsafe, scopeRemoveFinalizerUnsafe } from \"./internal/effect.js\";\nimport * as Layer from \"./Layer.js\";\nimport { hasProperty } from \"./Predicate.js\";\nimport * as Scope from \"./Scope.js\";\nconst TypeId = \"~effect/ManagedRuntime\";\n/**\n * Checks whether the provided argument is a `ManagedRuntime`.\n *\n * **When to use**\n *\n * Use to narrow an unknown value before treating it as a `ManagedRuntime`.\n *\n * **Details**\n *\n * The guard checks the internal `ManagedRuntime` marker property. It does not\n * build the layer or inspect the runtime's services.\n *\n * **Gotchas**\n *\n * Disposed runtimes still carry the marker, so this guard does not prove the\n * runtime is still usable.\n *\n * @see {@link make} for creating managed runtimes this guard recognizes\n *\n * @stability stable\n * @category guards\n * @since 3.9.0\n */\nexport const isManagedRuntime = input => hasProperty(input, TypeId);\n// The runtimes whose disposal the current fiber is running. A disposal adds its\n// runtime to the set it inherits, so a finalizer that disposes another runtime\n// still belongs to the outer disposals. Finalizers and their parallel fibers\n// inherit the set from the disposing fiber. It is not provided to the layer\n// build, because finalizers of layers shared through a MemoMap run with the\n// build context of the runtime that built them, which may not be the runtime\n// disposing them.\nconst DisposingRuntimes = /*#__PURE__*/Context.Reference(\"effect/ManagedRuntime/DisposingRuntimes\", {\n defaultValue: () => new Set()\n});\n/**\n * Creates a `ManagedRuntime` from a layer.\n *\n * **When to use**\n *\n * Use to create a reusable runtime from a `Layer` for application entry points\n * or integration code that runs many effects without rebuilding services.\n *\n * **Details**\n *\n * The layer is built lazily on first use and its context is cached for\n * subsequent runs. Resources acquired by the layer are owned by the runtime and\n * are released when `dispose` or `disposeEffect` is run. `options.memoMap` can\n * be used to share layer memoization with other layer builds.\n *\n * **Gotchas**\n *\n * Dispose the runtime when it is no longer needed. A runtime cannot be reused\n * after disposal.\n *\n * A failed layer build is also cached: subsequent runs return the same build\n * failure without rebuilding the layer. For transient failures, retry inside\n * the layer before passing it to `make`, or dispose the runtime and create a\n * new one to attempt a fresh build.\n *\n * **Example** (Creating a managed runtime)\n *\n * ```ts import.meta.vitest\n * import { Context, Effect, Layer, ManagedRuntime } from \"effect\"\n *\n * const notifications: Array<string> = []\n *\n * class Notifications extends Context.Service<Notifications, {\n * readonly notify: (message: string) => Effect.Effect<void>\n * }>()(\"Notifications\") {\n * static readonly layer = Layer.succeed(this)({\n * notify: Effect.fn(\"Notifications.notify\")((message) =>\n * Effect.sync(() => notifications.push(message))\n * )\n * })\n * }\n *\n * const runtime = ManagedRuntime.make(Notifications.layer)\n *\n * const program = Effect.flatMap(\n * Notifications,\n * (_) => _.notify(\"Hello, world!\")\n * ).pipe(Effect.ensuring(runtime.disposeEffect))\n *\n * await runtime.runPromise(program)\n * notifications // => [\"Hello, world!\"]\n * ```\n *\n * @see {@link ManagedRuntime} for the returned runtime interface\n * @see {@link Layer.MemoMap} for shared layer memoization\n * @see {@link Layer.build} for lower-level scoped layer construction\n *\n * @stability stable\n * @category constructors\n * @since 2.0.0\n */\nexport const make = (layer, options) => {\n const memoMap = options?.memoMap ?? Layer.makeMemoMapUnsafe();\n const scope = Scope.makeUnsafe(\"sequential\");\n const layerScope = Scope.forkUnsafe(scope, \"sequential\");\n const fiberScope = Scope.forkUnsafe(scope, \"parallel\");\n // Fibers started by the runtime, including the layer build, are interrupted\n // and awaited by its disposal, so they and their child fibers must not wait\n // for it.\n const managedFibers = new WeakSet();\n const disposingFibers = new WeakSet();\n const defaultRunOptions = {\n onFiberStart(fiber) {\n managedFibers.add(fiber);\n if (disposingFibers.has(fiber)) return;\n Fiber.runIn(fiber, fiberScope);\n }\n };\n const mergeRunOptions = options => options ? {\n ...options,\n onFiberStart: options.onFiberStart ? fiber => {\n defaultRunOptions.onFiberStart(fiber);\n options.onFiberStart(fiber);\n } : defaultRunOptions.onFiberStart\n } : defaultRunOptions;\n let buildFiber;\n let disposed;\n const contextEffect = Effect.withFiber(fiber => {\n if (!buildFiber) {\n buildFiber = Effect.runFork(Effect.tap(Layer.buildWithMemoMap(layer, memoMap, layerScope), context => Effect.sync(() => {\n self.cachedContext = context;\n })), {\n scheduler: fiber.cache.scheduler,\n // Unlike requests, the build joins fiberScope even if it disposed the\n // runtime, so disposal still interrupts it.\n onFiberStart(fiber) {\n managedFibers.add(fiber);\n Fiber.runIn(fiber, fiberScope);\n }\n });\n }\n return Effect.flatten(Fiber.await(buildFiber));\n });\n const self = {\n [TypeId]: TypeId,\n memoMap,\n scope,\n contextEffect: contextEffect,\n cachedContext: undefined,\n context() {\n return self.cachedContext === undefined ? Effect.runPromise(self.contextEffect) : Promise.resolve(self.cachedContext);\n },\n dispose() {\n return Effect.runPromise(self.disposeEffect);\n },\n [Symbol.asyncDispose]() {\n return self.dispose();\n },\n disposeEffect: Effect.withFiber(fiber => {\n if (disposed !== undefined) {\n if (fiber.getRef(DisposingRuntimes).has(self)) return Effect.void;\n for (let current = fiber; current; current = current._parent) {\n if (managedFibers.has(current)) return Effect.void;\n }\n return Deferred.await(disposed);\n }\n // Once `disposed` is set the close must run, or later calls would wait forever.\n fiberEnterUninterruptibleUnsafe(fiber);\n const done = disposed = Deferred.makeUnsafe();\n // Closing fiberScope interrupts and awaits every managed fiber. Exempt the\n // disposing fiber and its ancestors, which would otherwise await themselves.\n for (let current = fiber; current; current = current._parent) {\n disposingFibers.add(current);\n scopeRemoveFinalizerUnsafe(fiberScope, current);\n }\n ;\n self.contextEffect = Effect.die(\"ManagedRuntime disposed\");\n self.cachedContext = undefined;\n return Scope.close(self.scope, Exit.void).pipe(Effect.provideService(DisposingRuntimes, new Set(fiber.getRef(DisposingRuntimes)).add(self)), Effect.ensuring(Deferred.done(done, Exit.void)));\n }),\n runFork(effect, options) {\n return self.cachedContext === undefined ? Effect.runFork(provide(self, effect), mergeRunOptions(options)) : Effect.runForkWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runCallback(effect, options) {\n return self.cachedContext === undefined ? Effect.runCallback(provide(self, effect), mergeRunOptions(options)) : Effect.runCallbackWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runSyncExit(effect) {\n return self.cachedContext === undefined ? Effect.runSyncExit(provide(self, effect)) : Effect.runSyncExitWith(self.cachedContext)(effect);\n },\n runSync(effect) {\n return self.cachedContext === undefined ? Effect.runSync(provide(self, effect)) : Effect.runSyncWith(self.cachedContext)(effect);\n },\n runPromiseExit(effect, options) {\n return self.cachedContext === undefined ? Effect.runPromiseExit(provide(self, effect), mergeRunOptions(options)) : Effect.runPromiseExitWith(self.cachedContext)(effect, mergeRunOptions(options));\n },\n runPromise(effect, options) {\n return self.cachedContext === undefined ? Effect.runPromise(provide(self, effect), mergeRunOptions(options)) : Effect.runPromiseWith(self.cachedContext)(effect, mergeRunOptions(options));\n }\n };\n return self;\n};\nfunction provide(managed, effect) {\n return Effect.flatMap(managed.contextEffect, context => Effect.provideContext(effect, context));\n}\n//# sourceMappingURL=ManagedRuntime.js.map",
|
|
32
|
+
"/**\n * Service contract for command-line arguments and standard input, output, and\n * error output. It lets programs depend on standard I/O through the Effect\n * environment instead of reading from or writing to global process handles\n * directly.\n *\n * The service exposes arguments as an `Effect`, stdout and stderr as `Sink`s\n * that accept strings or bytes, and stdin as a byte `Stream`. This module also\n * provides a constructor for service values and a small test layer with\n * overridable defaults.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"./Context.js\";\nimport * as Effect from \"./Effect.js\";\nimport * as Layer from \"./Layer.js\";\nimport * as Sink from \"./Sink.js\";\nimport * as Stream from \"./Stream.js\";\n/**\n * Runtime identifier stored on `Stdio` service implementations.\n *\n * **Details**\n *\n * This marker is part of the runtime representation of `Stdio` service\n * implementations.\n *\n * @stability unstable\n * @category type IDs\n * @since 4.0.0\n */\nexport const TypeId = \"~effect/Stdio\";\n/**\n * Service tag for process standard I/O.\n *\n * **When to use**\n *\n * Use when you need command-line arguments or standard I/O streams supplied by\n * an effect's environment.\n *\n * @see {@link make} for constructing a `Stdio` service directly\n * @see {@link layerTest} for a test layer with defaults and overrides\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport const Stdio = /*#__PURE__*/Context.Service(TypeId);\n/**\n * Creates a `Stdio` service implementation from the provided fields and\n * attaches the `Stdio` type identifier.\n *\n * **When to use**\n *\n * Use when you need to assemble a concrete `Stdio` service from command-line\n * arguments and standard I/O implementations.\n *\n * **Details**\n *\n * The returned service reuses the supplied fields unchanged and adds the\n * `Stdio` type identifier. Omitted terminal-detection fields default to\n * effects that succeed with `false`.\n *\n * @see {@link layerTest} for a test layer with default fields that can be overridden\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = options => ({\n [TypeId]: TypeId,\n stdinIsTerminal: Effect.succeed(false),\n stdoutIsTerminal: Effect.succeed(false),\n stderrIsTerminal: Effect.succeed(false),\n ...options\n});\n/**\n * Creates a test layer for `Stdio`.\n *\n * **When to use**\n *\n * Use to provide deterministic standard I/O in tests while overriding only the\n * command-line arguments, input stream, or output sinks relevant to the case.\n *\n * **Details**\n *\n * Any provided fields override defaults. By default, arguments are empty,\n * standard output and error are draining sinks, and standard input is an empty\n * stream, and terminal-detection effects succeed with `false`.\n *\n * @see {@link make} for constructing a `Stdio` service directly without a `Layer` or defaults\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerTest = impl => Layer.succeed(Stdio, make({\n args: Effect.succeed([]),\n stdout: () => Sink.drain,\n stderr: () => Sink.drain,\n stdin: Stream.empty,\n ...impl\n}));\n//# sourceMappingURL=Stdio.js.map",
|
|
33
|
+
"import * as Context from \"./Context.js\";\nimport * as Predicate from \"./Predicate.js\";\nimport * as Schema from \"./Schema.js\";\nconst TypeId = \"~effect/Terminal\";\nconst QuitErrorTypeId = \"~effect/Terminal/QuitError\";\n/**\n * Represents an error that occurs when a user attempts to\n * quit out of a `Terminal` prompt for input (usually by entering `ctrl`+`c`).\n *\n * **When to use**\n *\n * Use when implementing terminal input or prompts that need to signal\n * user-requested cancellation through the typed error channel.\n *\n * @see {@link isQuitError} for checking unknown errors when handling terminal cancellation\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class QuitError extends /*#__PURE__*/Schema.Error(\"QuitError\")({\n _tag: /*#__PURE__*/Schema.tag(\"QuitError\")\n}) {\n /**\n * Marks this value as a terminal quit error for runtime guards.\n *\n * @since 4.0.0\n */\n [QuitErrorTypeId] = QuitErrorTypeId;\n}\n/**\n * Returns `true` if the provided value is a `Terminal.QuitError`.\n *\n * **When to use**\n *\n * Use to narrow unknown failures to `QuitError` when handling terminal input\n * cancellation.\n *\n * **Details**\n *\n * Returns `true` when the value carries the `QuitError` runtime marker and\n * narrows it to `QuitError`.\n *\n * @see {@link QuitError} for the error value produced when terminal input is quit\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isQuitError = u => Predicate.hasProperty(u, QuitErrorTypeId);\n/**\n * Service tag for command-line input and output services.\n *\n * **When to use**\n *\n * Use to access or provide platform terminal capabilities such as reading\n * input, writing output, and inspecting terminal dimensions.\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport const Terminal = /*#__PURE__*/Context.Service(\"effect/Terminal\");\n/**\n * Creates a `Terminal` service implementation.\n *\n * **When to use**\n *\n * Use to construct a custom `Terminal` service implementation from concrete\n * terminal capabilities when writing a platform adapter, test implementation,\n * or custom runtime service.\n *\n * **Details**\n *\n * The implementation object supplies `columns`, `rows`, `size`, `readInput`,\n * `readLine`, and `display`; `make` attaches the `Terminal` service marker so\n * the result can be provided through the `Terminal` context service.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = impl => Terminal.of({\n ...impl,\n [TypeId]: TypeId\n});\n//# sourceMappingURL=Terminal.js.map",
|
|
34
|
+
"/**\n * Key derivation: HKDF, PBKDF2, and Argon2id.\n *\n * The {@link Kdf} service derives bytes from a secret with an algorithm value\n * such as {@link hkdfSha256}, {@link pbkdf2Sha256}, or `argon2id()`. The\n * output is plain bytes: turn it into a typed key with the target family's raw\n * constructor, such as `Mac.key`.\n *\n * **Gotchas**\n *\n * - The secret is bytes, with no string overload. Encode passwords yourself,\n * and normalize their Unicode form first if users type them on different\n * platforms.\n * - `layerWebCrypto` does not provide Argon2id, because WebCrypto has no\n * Argon2. Deriving with it fails with an `Unsupported` reason, so programs\n * can fall back to PBKDF2. `NodeCrypto.layerKdf` provides Argon2id on\n * Node.js 24.7 or later and Bun 1.4.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Layer from \"../Layer.js\";\nimport * as CryptoError from \"./CryptoError.js\";\nimport * as Digest from \"./Digest.js\";\nimport * as internal from \"./internal/webCrypto.js\";\nimport { WebCrypto } from \"./WebCrypto.js\";\n/**\n * Builds the HKDF algorithm for a hash.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hkdf = hash => ({\n _tag: \"Hkdf\",\n name: `hkdf${Digest.nameSuffix(hash)}`,\n hash\n});\n/**\n * Builds a PBKDF2 algorithm for a hash and an iteration count.\n *\n * **Details**\n *\n * Deriving with an iteration count outside 1 to 2^31 - 1 fails with an\n * `InvalidArgument` reason.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const pbkdf2 = options => ({\n _tag: \"Pbkdf2\",\n name: `pbkdf2${Digest.nameSuffix(options.hash)}`,\n hash: options.hash,\n iterations: options.iterations\n});\n/**\n * HKDF with SHA-1.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hkdfSha1 = /*#__PURE__*/hkdf(Digest.sha1);\n/**\n * HKDF with SHA-256.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hkdfSha256 = /*#__PURE__*/hkdf(Digest.sha256);\n/**\n * HKDF with SHA-384.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hkdfSha384 = /*#__PURE__*/hkdf(Digest.sha384);\n/**\n * HKDF with SHA-512.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const hkdfSha512 = /*#__PURE__*/hkdf(Digest.sha512);\n/**\n * PBKDF2 with SHA-256 at 600,000 iterations, OWASP's current figure.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const pbkdf2Sha256 = /*#__PURE__*/pbkdf2({\n hash: Digest.sha256,\n iterations: 600_000\n});\n/**\n * Builds an Argon2id algorithm, with `memory` in KiB.\n *\n * **Details**\n *\n * Omitted costs default to RFC 9106's second recommended setting: 64 MiB of\n * memory (`65_536`), 3 passes, and 4 lanes.\n *\n * **Gotchas**\n *\n * `Kdf.layerWebCrypto` does not provide Argon2id. Use `NodeCrypto.layerKdf`,\n * or fall back to PBKDF2 on the `Unsupported` reason.\n *\n * @stability unstable\n * @category algorithms\n * @since 4.0.0\n */\nexport const argon2id = options => ({\n _tag: \"Argon2id\",\n name: \"argon2id\",\n memory: options?.memory ?? 65_536,\n passes: options?.passes ?? 3,\n parallelism: options?.parallelism ?? 4\n});\n/**\n * Service that derives bytes from a secret.\n *\n * **Example** (Deriving a key with HKDF)\n *\n * ```ts import.meta.vitest\n * import { Effect } from \"effect\"\n * import { Kdf } from \"effect/crypto\"\n *\n * const program = Effect.gen(function*() {\n * const kdf = yield* Kdf.Kdf\n * return yield* kdf.derive(Kdf.hkdfSha256, new Uint8Array(32), {\n * salt: new Uint8Array(16),\n * info: new TextEncoder().encode(\"encryption\"),\n * length: 32\n * })\n * })\n *\n * const bytes = await Effect.runPromise(program.pipe(Effect.provide(Kdf.layerWebCrypto)))\n * bytes.length // => 32\n * ```\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class Kdf extends /*#__PURE__*/Context.Service()(\"effect/crypto/Kdf\") {}\nconst invalidArgument = description => internal.fail(\"Kdf\", \"derive\", new CryptoError.InvalidArgument({\n description\n}));\nconst isIntegerIn = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;\n// Checks the arguments before they reach Web Crypto, which takes a 32-bit bit\n// length that some backends wrap instead of rejecting. Node.js aborts the\n// process on PBKDF2 iteration counts above 2^31 - 1.\nconst checkArguments = (algorithm, options) => {\n if (algorithm._tag !== \"Hkdf\" && options.info !== undefined) return invalidArgument(\"info only applies to HKDF\");\n if (algorithm._tag === \"Argon2id\") return undefined;\n if (algorithm.hash.name === \"MD5\") return invalidArgument(`${algorithm._tag} needs a SHA hash, not MD5`);\n if (algorithm._tag === \"Hkdf\") {\n const maxLength = 255 * algorithm.hash.outputLength;\n return isIntegerIn(options.length, 1, maxLength) ? undefined : invalidArgument(`length must be between 1 and ${maxLength} bytes for ${algorithm.name}`);\n }\n if (!isIntegerIn(algorithm.iterations, 1, 0x7fff_ffff)) {\n return invalidArgument(\"iterations must be between 1 and 2^31 - 1\");\n }\n return isIntegerIn(options.length, 1, 0x1fff_ffff) ? undefined : invalidArgument(\"length must be between 1 and 2^29 - 1 bytes\");\n};\nconst webCryptoParams = (algorithm, options) => algorithm._tag === \"Hkdf\" ? {\n name: \"HKDF\",\n hash: algorithm.hash.name,\n salt: options.salt,\n info: options.info ?? new Uint8Array()\n} : {\n name: \"PBKDF2\",\n hash: algorithm.hash.name,\n salt: options.salt,\n iterations: algorithm.iterations\n};\n/**\n * Layer that provides `Kdf` on the `WebCrypto` reference.\n *\n * **Details**\n *\n * HKDF and PBKDF2 run on `crypto.subtle`, off the event loop where the runtime\n * supports it. Argon2id fails with an `Unsupported` reason.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWebCrypto = /*#__PURE__*/Layer.effect(Kdf, /*#__PURE__*/WebCrypto.use(crypto => Effect.succeed(Kdf.of({\n derive: (algorithm, secret, options) => Effect.suspend(() => {\n const failure = checkArguments(algorithm, options);\n if (failure !== undefined) return failure;\n if (algorithm._tag === \"Argon2id\") {\n return internal.fail(\"Kdf\", \"derive\", new CryptoError.Unsupported({\n description: \"Kdf.layerWebCrypto does not provide argon2id\"\n }));\n }\n const name = algorithm._tag === \"Hkdf\" ? \"HKDF\" : \"PBKDF2\";\n return internal.run(\"Kdf\", \"derive\", algorithm.name, crypto, async subtle => {\n const handle = await subtle.importKey(\"raw\", secret, name, false, [\"deriveBits\"]);\n return new Uint8Array(await subtle.deriveBits(webCryptoParams(algorithm, options), handle, options.length * 8));\n });\n })\n}))));\n//# sourceMappingURL=Kdf.js.map",
|
|
35
|
+
"/**\n * Node.js layers for the `effect/crypto` modules, also used by Bun.\n *\n * {@link layerDigest} runs MD5 and SHA on `node:crypto`, {@link layerMac} runs\n * HMAC on `node:crypto`, {@link layerKdf} adds Argon2id, {@link layerAead}\n * runs ChaCha20-Poly1305 on `node:crypto`, and {@link layerSecureRandom},\n * {@link layerCipher}, {@link layerSignature}, {@link layerKeyAgreement}, and\n * {@link layerKeyWrap} run the core WebCrypto layers. Each Node.js layer\n * handles only the algorithms and keys it exists for and hands the rest to\n * the core WebCrypto implementation. Layers that need `SecureRandom` get it\n * from {@link layerSecureRandom}, so no layer here has requirements.\n * {@link layer} provides every family at once; provide a family's own layer to\n * pick services selectively.\n *\n * `CryptoKey`-backed keys go through Node.js's `crypto.subtle`, because\n * `KeyObject.from(cryptoKey)` is deprecated (DEP0204). A `CryptoKey` must\n * come from the `WebCrypto` reference: Node.js rejects one from another\n * reference with a `TypeError`, which is a defect.\n *\n * @stability unstable\n * @since 1.0.0\n */\nimport * as Aead from \"effect/crypto/Aead\";\nimport * as Cipher from \"effect/crypto/Cipher\";\nimport * as CryptoError from \"effect/crypto/CryptoError\";\nimport * as Digest from \"effect/crypto/Digest\";\nimport * as Kdf from \"effect/crypto/Kdf\";\nimport * as KeyAgreement from \"effect/crypto/KeyAgreement\";\nimport * as KeyWrap from \"effect/crypto/KeyWrap\";\nimport * as Mac from \"effect/crypto/Mac\";\nimport * as SecureRandom from \"effect/crypto/SecureRandom\";\nimport * as Signature from \"effect/crypto/Signature\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as NodeCrypto from \"node:crypto\";\n/**\n * Layer that provides `SecureRandom` from `getRandomValues` on the `WebCrypto`\n * reference.\n *\n * **Details**\n *\n * This is `SecureRandom.layerWebCrypto`, re-exported so that Node.js programs\n * take every crypto layer from `NodeCrypto`. `node:crypto` adds nothing here.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerSecureRandom = SecureRandom.layerWebCrypto;\nconst nodeHashNames = {\n \"MD5\": \"md5\",\n \"SHA-1\": \"sha1\",\n \"SHA-256\": \"sha256\",\n \"SHA-384\": \"sha384\",\n \"SHA-512\": \"sha512\"\n};\n// Copies the Buffer, which may be a view into Node's shared pool.\nconst nodeDigest = (algorithm, data) => new Uint8Array(NodeCrypto.createHash(nodeHashNames[algorithm.name]).update(data).digest());\n/**\n * Layer that provides `Digest` using `createHash` from `node:crypto`.\n *\n * **Details**\n *\n * MD5 and the SHA algorithms run synchronously on `node:crypto`. On Node.js,\n * `crypto.subtle.digest` sends each call to the threadpool, which is\n * noticeably slower for small inputs. Output is identical to\n * `Digest.layerWebCrypto`.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerDigest = /*#__PURE__*/Layer.succeed(Digest.Digest, {\n digest: (algorithm, data) => Effect.sync(() => nodeDigest(algorithm, data)),\n digestHex: (algorithm, data) => Effect.sync(() => NodeCrypto.createHash(nodeHashNames[algorithm.name]).update(data).digest(\"hex\"))\n});\n// Copies the Buffer, which may be a view into Node's shared pool.\nconst nodeHmac = (hash, key, data) => new Uint8Array(NodeCrypto.createHmac(nodeHashNames[hash], key).update(data).digest());\n/**\n * Layer that provides `Mac` using `createHmac` from `node:crypto`.\n *\n * **Details**\n *\n * Byte-backed keys sign and verify synchronously on `node:crypto`, since\n * webhook verification is a server hot path. `CryptoKey`-backed keys go\n * through Node.js's `crypto.subtle`, and generated keys come from\n * {@link layerSecureRandom}. This is `Mac.layerWebCryptoWith` with a\n * `node:crypto` primitive, so output and errors are identical to\n * `Mac.layerWebCrypto`.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerMac = /*#__PURE__*/Mac.layerWebCryptoWith({\n hmac: nodeHmac\n}).pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\nconst kdfFailure = reason => Effect.fail(new CryptoError.CryptoError({\n module: \"Kdf\",\n method: \"derive\",\n reason\n}));\nconst argon2Unsupported = cause => kdfFailure(new CryptoError.Unsupported({\n description: \"NodeCrypto.layerKdf does not provide argon2id on this runtime\",\n ...(cause === undefined ? {} : {\n cause\n })\n}));\n// Only a missing Argon2id engine is a typed failure; anything else is a defect.\nconst argon2Failure = cause => typeof cause === \"object\" && cause !== null && \"code\" in cause && cause.code === \"ERR_CRYPTO_ARGON2_NOT_SUPPORTED\" ? argon2Unsupported(cause) : Effect.die(cause);\nconst isIntegerIn = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;\n// The RFC 9106 bounds, checked before `node:crypto`, which throws on them.\nconst argon2Problem = (algorithm, options) => {\n if (options.info !== undefined) return \"info only applies to HKDF\";\n const uint32 = n => isIntegerIn(n, 1, 0xffff_ffff);\n if (!uint32(algorithm.passes) || !isIntegerIn(algorithm.parallelism, 1, 0xff_ffff)) {\n return \"passes must be between 1 and 2^32 - 1 and parallelism between 1 and 2^24 - 1\";\n }\n if (!uint32(algorithm.memory) || algorithm.memory < 8 * algorithm.parallelism) {\n return \"memory must be at least 8 KiB per lane and below 2^32 KiB\";\n }\n if (options.salt.length < 8) return \"salt must be at least 8 bytes\";\n return isIntegerIn(options.length, 4, 0xffff_ffff) ? undefined : \"length must be between 4 and 2^32 - 1 bytes\";\n};\nconst argon2id = (algorithm, secret, options) => Effect.callback(resume => {\n const problem = argon2Problem(algorithm, options);\n if (problem !== undefined) return resume(kdfFailure(new CryptoError.InvalidArgument({\n description: problem\n })));\n // Checked at call time, since Node.js added `argon2` in 24.7.\n if (typeof NodeCrypto.argon2 !== \"function\") return resume(argon2Unsupported());\n try {\n NodeCrypto.argon2(\"argon2id\", {\n message: secret,\n nonce: options.salt,\n memory: algorithm.memory,\n passes: algorithm.passes,\n parallelism: algorithm.parallelism,\n tagLength: options.length\n }, (cause, key) => {\n if (cause) resume(argon2Failure(cause));else resume(Effect.succeed(new Uint8Array(key.buffer, key.byteOffset, key.length)));\n });\n } catch (cause) {\n resume(argon2Failure(cause));\n }\n}).pipe(Effect.uninterruptible);\n/**\n * Layer that provides `Kdf`, adding Argon2id from `node:crypto`.\n *\n * **Details**\n *\n * Argon2id runs on `argon2` from `node:crypto`, which needs Node.js 24.7 or\n * later linked against OpenSSL 3.2, or Bun 1.4. Support is checked at call\n * time: on other runtimes, deriving with Argon2id fails with an `Unsupported`\n * reason. HKDF and PBKDF2 go through `Kdf.layerWebCrypto`, which keeps them\n * off the event loop.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerKdf = /*#__PURE__*/Layer.effect(Kdf.Kdf, Effect.gen(function* () {\n const core = yield* Kdf.Kdf;\n return Kdf.Kdf.of({\n derive: (algorithm, secret, options) => algorithm._tag === \"Argon2id\" ? argon2id(algorithm, secret, options) : core.derive(algorithm, secret, options)\n });\n})).pipe(/*#__PURE__*/Layer.provide(Kdf.layerWebCrypto));\n// Copies into a fresh array, wiping the parts, so no plaintext stays in\n// Node.js's shared Buffer pool.\nconst concat = parts => {\n const output = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));\n let offset = 0;\n for (const part of parts) {\n output.set(part, offset);\n offset += part.length;\n part.fill(0);\n }\n return output;\n};\nconst nodeChacha = {\n encrypt: (key, nonce, plaintext, aad) => {\n const cipher = NodeCrypto.createCipheriv(\"chacha20-poly1305\", key, nonce, {\n authTagLength: 16\n });\n cipher.setAAD(aad);\n return concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]);\n },\n decrypt: (key, nonce, ciphertext, aad) => {\n const decipher = NodeCrypto.createDecipheriv(\"chacha20-poly1305\", key, nonce, {\n authTagLength: 16\n });\n decipher.setAAD(aad);\n decipher.setAuthTag(ciphertext.subarray(ciphertext.length - 16));\n const plaintext = decipher.update(ciphertext.subarray(0, ciphertext.length - 16));\n try {\n // `final` throws only when the tag does not match.\n return concat([plaintext, decipher.final()]);\n } catch {\n plaintext.fill(0);\n return undefined;\n }\n }\n};\n/**\n * Layer that provides `Aead`, running ChaCha20-Poly1305 on `node:crypto`.\n *\n * **Details**\n *\n * Byte-backed ChaCha20-Poly1305 keys encrypt and decrypt synchronously on\n * `node:crypto`. AES-GCM runs on `crypto.subtle` and XChaCha20-Poly1305 on its\n * pure TypeScript implementation. This is `Aead.layerWebCryptoWith` with a\n * `node:crypto` implementation, so arguments are checked and errors reported\n * as in `Aead.layerWebCrypto`. Bun's `node:crypto` lacks ChaCha20-Poly1305, so\n * on Bun this layer runs the core implementation. Output is identical to\n * `Aead.layerWebCrypto`. Generated keys come from {@link layerSecureRandom}.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerAead = /*#__PURE__*/Aead.layerWebCryptoWith(NodeCrypto.getCiphers().includes(\"chacha20-poly1305\") ? {\n implementations: {\n chacha20Poly1305: nodeChacha\n }\n} : {}).pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\n/**\n * Layer that provides `Cipher` from `crypto.subtle` on the `WebCrypto`\n * reference.\n *\n * **Details**\n *\n * This is `Cipher.layerWebCrypto` with {@link layerSecureRandom}, so that\n * Node.js programs take every crypto layer from `NodeCrypto`. Node.js's\n * `crypto.subtle` already runs AES-CTR and AES-CBC on OpenSSL.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerCipher = /*#__PURE__*/Cipher.layerWebCrypto.pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\n/**\n * Layer that provides `Signature` on Node.js's `crypto.subtle`.\n *\n * **Details**\n *\n * This is `Signature.layerWebCrypto` with {@link layerSecureRandom}, so that\n * Node.js programs take every crypto layer from `NodeCrypto`.\n * `CryptoKey`-backed keys go through Node.js's `crypto.subtle`, because\n * `KeyObject.from(cryptoKey)` is deprecated (DEP0204).\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerSignature = /*#__PURE__*/Signature.layerWebCrypto.pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\n/**\n * Layer that provides `KeyAgreement` on Node.js's `crypto.subtle`.\n *\n * **Details**\n *\n * This is `KeyAgreement.layerWebCrypto` with {@link layerSecureRandom}, so\n * that Node.js programs take every crypto layer from `NodeCrypto`.\n * `CryptoKey`-backed keys go through Node.js's `crypto.subtle`, because\n * `KeyObject.from(cryptoKey)` is deprecated (DEP0204).\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerKeyAgreement = /*#__PURE__*/KeyAgreement.layerWebCrypto.pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\n/**\n * Layer that provides `KeyWrap` on Node.js's `crypto.subtle`.\n *\n * **Details**\n *\n * This is `KeyWrap.layerWebCrypto` with {@link layerSecureRandom}, so that\n * Node.js programs take every crypto layer from `NodeCrypto`. Node.js's\n * `crypto.subtle` runs AES-KW and RSA-OAEP on OpenSSL. `CryptoKey`-backed\n * keys go through it, because `KeyObject.from(cryptoKey)` is deprecated\n * (DEP0204).\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerKeyWrap = /*#__PURE__*/KeyWrap.layerWebCrypto.pipe(/*#__PURE__*/Layer.provide(layerSecureRandom));\n/**\n * Layer that provides every `effect/crypto` service with the Node.js\n * implementations.\n *\n * **Details**\n *\n * This merges the family layers of this module, so it requires nothing. It\n * keeps the `node:crypto` implementations of {@link layerDigest},\n * {@link layerMac}, {@link layerKdf}, and {@link layerAead}.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.mergeAll(layerSecureRandom, layerDigest, layerMac, layerKdf, layerAead, layerCipher, layerSignature, layerKeyAgreement, layerKeyWrap);\n//# sourceMappingURL=NodeCrypto.js.map",
|
|
36
|
+
"/**\n * Service boundary for starting and controlling child processes.\n *\n * `ChildProcessSpawner` is the service used by `ChildProcess` commands to start\n * operating-system processes. A spawner turns a command description into a\n * handle that can write to stdin, read stdout and stderr, wait for exit, kill\n * the process, and manage whether the process keeps its parent alive. Platform\n * backends implement this service, while most application code uses the higher\n * level `ChildProcess` module.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Brand from \"../Brand.js\";\nimport * as Context from \"../Context.js\";\nimport * as Effect from \"../Effect.js\";\nimport * as Inspectable from \"../Inspectable.js\";\nimport * as Stream from \"../Stream.js\";\n/**\n * Constructs branded child process `ExitCode` values.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const ExitCode = /*#__PURE__*/Brand.nominal();\n/**\n * Constructs branded child process `ProcessId` values.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const ProcessId = /*#__PURE__*/Brand.nominal();\nconst HandleTypeId = \"~effect/process/ChildProcessSpawner/ChildProcessHandle\";\nconst HandleProto = {\n [HandleTypeId]: HandleTypeId,\n ...Inspectable.BaseProto,\n toJSON() {\n return {\n _id: \"ChildProcessHandle\",\n pid: this.pid\n };\n }\n};\n/**\n * Constructs a new `ChildProcessHandle`.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const makeHandle = params => Object.setPrototypeOf({\n ...params\n}, HandleProto);\n/**\n * Creates a `ChildProcessSpawner` service from a `spawn` function, deriving\n * helpers for exit codes and output collection from that implementation.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = spawn => {\n // The helpers own the handle, so they drain any output they do not return\n // to keep a full pipe from blocking the child.\n const streamString = (command, options) => spawn(command).pipe(Effect.map(handle => Stream.decodeText(options?.includeStderr === true ? handle.all : Stream.drainFork(handle.stdout, handle.stderr))), Stream.unwrap);\n const streamLines = (command, options) => Stream.splitLines(streamString(command, options));\n return ChildProcessSpawner.of({\n spawn,\n // Return once the process exits, even if descendants keep the pipes open.\n exitCode: command => Effect.scoped(Effect.flatMap(spawn(command), handle => Effect.raceFirst(handle.exitCode, Effect.andThen(Stream.runDrain(handle.all), Effect.never)))),\n streamString,\n streamLines,\n lines: (command, options) => Stream.runCollect(streamLines(command, options)),\n string: (command, options) => Stream.mkString(streamString(command, options))\n });\n};\n/**\n * Service tag for child process spawning.\n *\n * @stability unstable\n * @category services\n * @since 4.0.0\n */\nexport class ChildProcessSpawner extends /*#__PURE__*/Context.Service()(\"effect/process/ChildProcessSpawner\") {}\n//# sourceMappingURL=ChildProcessSpawner.js.map",
|
|
37
|
+
"/**\n * Builds command lines, the single strings that a shell or a Windows program\n * turns back into arguments, and argument lists from templates. It is\n * unrelated to `effect/cli`, which parses the arguments of your own program.\n *\n * The rules depend on what parses the string, not on the platform that builds\n * it, so `quote`, `join` and `display` take an explicit `format`:\n *\n * - `\"posix\"` (the default) for `sh`, `dash`, `bash` and `zsh`. Quoted output\n * is also read the same way by `fish`.\n * - `\"powershell\"` for PowerShell 7.3 or later.\n * - `\"windows\"` for the Microsoft C runtime rules that most Windows programs\n * use to split their command line.\n *\n * SSH sends one command line to the login shell of the remote account, so the\n * format must match that shell. The remote shell must be a POSIX shell or\n * PowerShell: Windows OpenSSH uses `cmd.exe` by default, which no format\n * supports, so set its `DefaultShell` to PowerShell. Docker and Kubernetes exec\n * take argument lists and need no command line at all.\n *\n * Arguments can be `Redacted` strings. `quote` and `join` include their values,\n * because their output is meant to run, while `display` replaces them with\n * `<redacted>`.\n *\n * @stability unstable\n * @since 4.0.7\n */\nimport * as Data from \"../Data.js\";\nimport * as Redacted from \"../Redacted.js\";\nimport * as Result from \"../Result.js\";\n/**\n * Error returned when a command line or a template cannot be built.\n *\n * **Details**\n *\n * - `NulCharacter`: an argument passed to {@link quote} or {@link join}\n * contains a NUL character, which no command line can carry.\n * - `InvalidArgument`: the format cannot carry an argument: a Windows program\n * name with a double quote, or the argument `--%`, which PowerShell drops\n * when it calls a native program.\n * - `InvalidEscape`: template text ends with a backslash that escapes nothing,\n * or contains an invalid JavaScript escape sequence.\n * - `UnterminatedQuote`: a quoted section of a template is not closed.\n * - `UnsupportedSyntax`: template text contains shell syntax that cannot work\n * without a shell, such as operators, expansions, globs, comments or\n * variable assignments, or an interpolated array is not a separate argument.\n *\n * Messages never include the input, which may contain secrets.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.7\n */\nexport class CommandLineError extends /*#__PURE__*/Data.TaggedError(\"CommandLineError\") {}\n/**\n * Quotes one argument so that a program reading the given format sees it as\n * exactly one argument, with one PowerShell exception listed under Gotchas.\n *\n * **When to use**\n *\n * Use when you insert an argument into a command line that is otherwise\n * written by hand, for example a script passed to `sh -c`.\n *\n * **Details**\n *\n * - `\"posix\"` leaves words made of letters, digits and `_ @ + : , . / -`\n * unchanged and wraps everything else in single quotes. Single quotes and\n * backslashes are written outside the quotes, so `fish` reads the result\n * the same way.\n * - `\"powershell\"` always uses single quotes, doubling `'` and the\n * typographic single quotes that PowerShell also accepts as quotes.\n * - `\"windows\"` quotes words that contain a space, a tab, a line break or a\n * double quote, using the C runtime backslash rules. Use {@link join} for a\n * complete command line, because the program name follows different rules.\n *\n * **Gotchas**\n *\n * - The result contains the value of a `Redacted` argument. Use\n * {@link display} for logs.\n * - Control characters are kept as they are. That is safe for `sh -c` and SSH\n * commands, but not for text typed into an interactive shell.\n * - PowerShell never passes an argument equal to `--%` to a native program,\n * however it is quoted. Use {@link join} for a whole native call, which\n * fails with `InvalidArgument` instead.\n *\n * **Example** (Quoting arguments for different shells)\n *\n * ```ts import.meta.vitest\n * import { Result } from \"effect\"\n * import { CommandLine } from \"effect/process\"\n *\n * CommandLine.quote(\"it's\") // => Result.succeed(\"'it'\\\\''s'\")\n * CommandLine.quote(\"it's\", { format: \"powershell\" }) // => Result.succeed(\"'it''s'\")\n * CommandLine.quote(\"C:\\\\My Files\\\\\", { format: \"windows\" }) // => Result.succeed(\"\\\"C:\\\\My Files\\\\\\\\\\\"\")\n * ```\n *\n * @see {@link join} for quoting a whole argument list\n *\n * @stability unstable\n * @category encoding\n * @since 4.0.7\n */\nexport const quote = (word, options) => {\n const value = unwrap(word);\n if (value.includes(\"\\0\")) return failNul(\"The argument\");\n return Result.succeed(quoteWord(options?.format ?? \"posix\", value, false));\n};\n/**\n * Builds a command line that runs the given program and arguments.\n *\n * **When to use**\n *\n * Use when a transport accepts only one string, such as an SSH exec request or\n * a `shell` option, and the arguments must reach the program unchanged.\n *\n * **Details**\n *\n * The first word is the program. Each word is quoted as in {@link quote} and\n * the words are separated by spaces.\n *\n * - `\"posix\"` also quotes a program name that `sh`, `bash`, `zsh` or `fish`\n * reads as syntax, such as `if` or `time`.\n * - `\"powershell\"` starts the line with the call operator `&`, because a\n * quoted program name is otherwise read as a string value.\n * - `\"windows\"` quotes the program name with the C runtime rules for program\n * names, which do not support backslash escapes.\n * - An empty list returns an empty string.\n *\n * **Gotchas**\n *\n * - The result contains the values of `Redacted` arguments. Use\n * {@link display} for logs.\n * - A Windows program name that contains `\"` fails with `InvalidArgument`.\n * - For `\"powershell\"`, an argument equal to `--%` fails with\n * `InvalidArgument`: PowerShell drops it when it calls a native program,\n * however it is quoted.\n * - `\"windows\"` output is the command line of a program, not a `cmd.exe`\n * script. `cmd.exe`, which `shell: true` uses on Windows, expands `%NAME%`\n * and reads `^ & | < >` before the program sees its arguments, so a script\n * that contains untrusted values has to be written by hand.\n *\n * **Example** (Joining arguments into command lines)\n *\n * ```ts import.meta.vitest\n * import { Result } from \"effect\"\n * import { CommandLine } from \"effect/process\"\n *\n * const args = [\"git\", \"commit\", \"-m\", \"fix: don't fail\"]\n *\n * CommandLine.join(args) // => Result.succeed(\"git commit -m 'fix: don'\\\\''t fail'\")\n * CommandLine.join(args, { format: \"powershell\" }) // => Result.succeed(\"& 'git' 'commit' '-m' 'fix: don''t fail'\")\n * CommandLine.join(args, { format: \"windows\" }) // => Result.succeed(\"git commit -m \\\"fix: don't fail\\\"\")\n * ```\n *\n * @see {@link display} for rendering a command for logs and error messages\n *\n * @stability unstable\n * @category encoding\n * @since 4.0.7\n */\nexport const join = (words, options) => {\n const values = [];\n for (let i = 0; i < words.length; i++) {\n const value = unwrap(words[i]);\n if (value.includes(\"\\0\")) return failNul(`Argument ${i}`);\n values.push(value);\n }\n if (values.length === 0) return Result.succeed(\"\");\n const format = options?.format ?? \"posix\";\n if (format === \"powershell\") {\n const stopParsing = values.indexOf(\"--%\", 1);\n if (stopParsing !== -1) {\n return Result.fail(new CommandLineError({\n reason: \"InvalidArgument\",\n message: `Argument ${stopParsing} is \"--%\", which PowerShell drops when it calls a program`\n }));\n }\n } else if (format === \"windows\" && values[0].includes(\"\\\"\")) {\n return Result.fail(new CommandLineError({\n reason: \"InvalidArgument\",\n message: \"A Windows program name cannot contain a double quote\"\n }));\n }\n return Result.succeed(joinWords(format, values.map((value, i) => quoteWord(format, value, i === 0))));\n};\n/**\n * Renders a command for logs and error messages.\n *\n * **When to use**\n *\n * Use when you show a command to a person, for example in an error message,\n * and secrets and control characters must not reach the output.\n *\n * **Details**\n *\n * - Quotes like {@link join}, so commands without control characters or\n * secrets can be copied into a terminal of the given format.\n * - Replaces `Redacted` arguments with `<redacted>`.\n * - Writes control characters and Unicode line separators as escapes such as\n * `\\n` or `\\u001b`, so output cannot move the cursor or inject terminal\n * sequences.\n * - Never fails: input that {@link join} rejects is rendered anyway.\n *\n * **Gotchas**\n *\n * The output is for reading only. It is not a reliable command line: escapes\n * and `<redacted>` change what a shell would run.\n *\n * **Example** (Showing a command with a secret)\n *\n * ```ts import.meta.vitest\n * import { Redacted } from \"effect\"\n * import { CommandLine } from \"effect/process\"\n *\n * const token = Redacted.make(\"hunter2\")\n *\n * CommandLine.display([\"curl\", \"-H\", token, \"https://x.dev/a b\"]) // => \"curl -H <redacted> 'https://x.dev/a b'\"\n * ```\n *\n * @see {@link join} for building a command line to run\n *\n * @stability unstable\n * @category encoding\n * @since 4.0.7\n */\nexport const display = (words, options) => {\n if (words.length === 0) return \"\";\n const format = options?.format ?? \"posix\";\n // Escaping after quoting keeps the escapes inside the quotes.\n return joinWords(format, words.map((word, i) => Redacted.isRedacted(word) ? \"<redacted>\" : escapeControlCharacters(quoteWord(format, word, i === 0))));\n};\n/**\n * Builds an argument list from a template literal.\n *\n * **When to use**\n *\n * Use to write a command as it would look in a shell while keeping every\n * interpolated value a literal argument.\n *\n * **Details**\n *\n * - The template text is split into words as a POSIX shell does: spaces,\n * tabs and line breaks separate words, and quotes and backslash escapes are\n * removed. A long command can span several lines.\n * - Text that would need a shell fails with `UnsupportedSyntax`: operators\n * (`| & ; < > ( )`), expansions (`$NAME`, `${...}`, `$(...)`, backticks, a\n * leading `~`, braces such as `{a,b}`, and a leading `=` that `zsh`\n * expands), globs (`* ? [`), comments (`#` at the start of a word), and a\n * variable assignment in the program position. Quote such characters to\n * pass them literally.\n * - No shell runs, so a program such as `if` or `time` names an executable.\n * - Each `${}` value is inserted literally, without splitting or quote\n * processing. Next to other text or inside quotes, it becomes part of the\n * surrounding argument.\n * - An array adds one argument per element and must stand alone as a whole\n * argument.\n * - Numbers and booleans are converted with `String`.\n * - An argument that contains a `Redacted` value becomes `Redacted` as a\n * whole.\n *\n * **Gotchas**\n *\n * - An invalid JavaScript escape sequence in the text, such as `\\u` without\n * hex digits, fails with `InvalidEscape`. Use `String.raw` or a `${}` value\n * for backslashes.\n * - Neither the text nor the values are checked for NUL characters.\n * {@link join} and the child process spawners reject them where they would\n * truncate an argument.\n *\n * **Example** (Building arguments with interpolated values)\n *\n * ```ts import.meta.vitest\n * import { Redacted, Result } from \"effect\"\n * import { CommandLine } from \"effect/process\"\n *\n * const msg = \"fix: handle $HOME\"\n * const files = [\"a.ts\", \"b.ts\"]\n *\n * CommandLine.template`git commit -m ${msg} ${files}` // => Result.succeed([\"git\", \"commit\", \"-m\", msg, ...files])\n *\n * const password = Redacted.make(\"hunter2\")\n * const words = Result.getOrThrow(CommandLine.template`psql \"--password=${password}\"`)\n *\n * CommandLine.display(words) // => \"psql <redacted>\"\n * ```\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.7\n */\nexport const template = (strings, ...expressions) => {\n const index = strings.findIndex(text => text === undefined);\n if (index !== -1) {\n return Result.fail(new CommandLineError({\n reason: \"InvalidEscape\",\n message: `Template part ${index} contains an invalid escape sequence`\n }));\n }\n return parseTemplate(strings, expressions);\n};\n// -----------------------------------------------------------------------------\n// Quoting\n// -----------------------------------------------------------------------------\nconst unwrap = item => Redacted.isRedacted(item) ? Redacted.value(item) : String(item);\nconst toWord = item => Redacted.isRedacted(item) ? item : String(item);\nconst failNul = subject => Result.fail(new CommandLineError({\n reason: \"NulCharacter\",\n message: `${subject} contains a NUL character`\n}));\n// Words that sh, bash, zsh or fish read as syntax in the program position. A\n// quoted reserved word is an ordinary command name.\nconst reservedWords = /*#__PURE__*/new Set([\"!\", \"{\", \"}\", \"and\", \"begin\", \"case\", \"coproc\", \"do\", \"done\", \"elif\", \"else\", \"end\", \"esac\", \"fi\", \"for\", \"foreach\", \"function\", \"if\", \"in\", \"nocorrect\", \"not\", \"or\", \"repeat\", \"select\", \"switch\", \"then\", \"time\", \"until\", \"while\"]);\n// Quotes one word for the format. The program, the first word, follows\n// different rules from the arguments in POSIX shells and in Windows programs.\nconst quoteWord = (format, value, program) => {\n switch (format) {\n case \"posix\":\n return program && reservedWords.has(value) ? `'${value}'` : quotePosix(value);\n case \"powershell\":\n return quotePowerShell(value);\n case \"windows\":\n return program && !value.includes(\"\\\"\") ? quoteWindowsProgram(value) : quoteWindowsArgument(value);\n }\n};\nconst joinWords = (format, quoted) => format === \"powershell\" ? `& ${quoted.join(\" \")}` : quoted.join(\" \");\nconst posixSafe = /^[A-Za-z0-9_@+:,./-]+$/;\n// Single quotes keep every character literal in POSIX shells. `'` and `\\` are\n// written outside the quotes, because fish also treats `\\'` and `\\\\` as\n// escapes inside single quotes.\nconst quotePosix = value => posixSafe.test(value) ? value : `'${value.replace(/['\\\\]/g, char => `'\\\\${char}'`)}'`;\n// PowerShell also reads the typographic single quotes U+2018 to U+201B as\n// quotes, so each of them is doubled like `'`.\nconst quotePowerShell = value => `'${value.replace(/['\\u2018\\u2019\\u201A\\u201B]/g, \"$&$&\")}'`;\nconst windowsNeedsQuotes = /[ \\t\\n\\v\"]/;\n// Arguments: 2n backslashes before a quote mean n backslashes, 2n+1 mean n\n// backslashes and a literal quote, and other backslashes are literal.\nconst quoteWindowsArgument = value => {\n if (value.length > 0 && !windowsNeedsQuotes.test(value)) return value;\n let out = \"\\\"\";\n let backslashes = 0;\n for (const char of value) {\n if (char === \"\\\\\") {\n backslashes++;\n } else if (char === \"\\\"\") {\n out += \"\\\\\".repeat(backslashes * 2 + 1) + \"\\\"\";\n backslashes = 0;\n } else {\n out += \"\\\\\".repeat(backslashes) + char;\n backslashes = 0;\n }\n }\n return out + \"\\\\\".repeat(backslashes * 2) + \"\\\"\";\n};\n// Program names allow quotes for grouping but no backslash escapes.\nconst quoteWindowsProgram = value => value.length > 0 && !/[ \\t]/.test(value) ? value : `\"${value}\"`;\n// oxlint-disable-next-line no-control-regex\nconst controlCharacters = /[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]/g;\nconst controlEscapes = {\n \"\\n\": \"\\\\n\",\n \"\\r\": \"\\\\r\",\n \"\\t\": \"\\\\t\"\n};\nconst escapeControlCharacters = value => value.replace(controlCharacters, char => controlEscapes[char] ?? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, \"0\")}`);\n// -----------------------------------------------------------------------------\n// Templates\n// -----------------------------------------------------------------------------\nconst operators = \"|&;<>()\";\nconst globs = \"*?[\";\nconst expansionStart = /[A-Za-z_0-9{(@*#?$!'\"-]/;\nconst quotedExpansionStart = /[A-Za-z_0-9{(@*#?$!-]/;\nconst assignmentName = /^[A-Za-z_][A-Za-z0-9_]*\\+?$/;\nconst isBlank = char => char === \" \" || char === \"\\t\" || char === \"\\n\";\n// Why an unquoted character needs a shell, if it does.\nconst unsupportedSyntax = (char, next, wordStart) => {\n if (operators.includes(char)) return `The operator \"${char}\" needs a shell`;\n if (char === \"`\") return \"Command substitution needs a shell\";\n if (char === \"$\" && next !== undefined && expansionStart.test(next)) return `The expansion \"$${next}\" needs a shell`;\n if (globs.includes(char)) return `The glob character \"${char}\" needs a shell`;\n if (!wordStart) return undefined;\n if (char === \"#\") return \"A comment needs a shell\";\n if (char === \"~\") return \"Tilde expansion needs a shell\";\n if (char === \"=\" && next !== undefined && !isBlank(next)) return \"A leading \\\"=\\\" is expanded by zsh\";\n return undefined;\n};\n// Splits the text parts with POSIX quote removal and inserts the values\n// between them.\nconst parseTemplate = (texts, values) => {\n const words = [];\n // The current word, empty until it starts. An opened quote adds \"\".\n let word = [];\n // The current word is unquoted literal text, so it can be the name of a\n // variable assignment.\n let plain = true;\n let braceDepth = 0;\n let quote = undefined;\n let quotePart = 0;\n let part = 0;\n const error = (reason, message, at = part) => Result.fail(new CommandLineError({\n reason,\n message: `${message} in template part ${at}`\n }));\n const endWord = () => {\n if (word.length === 0) return;\n const value = word.map(unwrap).join(\"\");\n words.push(word.length === 1 && Redacted.isRedacted(word[0]) ? word[0] : word.some(Redacted.isRedacted) ? Redacted.make(value) : value);\n word = [];\n plain = true;\n braceDepth = 0;\n };\n const scan = text => {\n for (let i = 0; i < text.length; i++) {\n const char = text[i];\n const next = text[i + 1];\n if (quote === \"'\") {\n if (char === \"'\") quote = undefined;else word.push(char);\n } else if (quote === \"\\\"\") {\n if (char === \"\\\"\") {\n quote = undefined;\n } else if (char === \"\\\\\" && next !== undefined && \"$`\\\"\\\\\\n\".includes(next)) {\n if (next !== \"\\n\") word.push(next);\n i++;\n } else if (char === \"`\") {\n return error(\"UnsupportedSyntax\", \"Command substitution needs a shell\");\n } else if (char === \"$\" && next !== undefined && quotedExpansionStart.test(next)) {\n return error(\"UnsupportedSyntax\", `The expansion \"$${next}\" needs a shell`);\n } else {\n word.push(char);\n }\n } else if (isBlank(char)) {\n endWord();\n } else if (char === \"\\\\\") {\n if (next === undefined) return error(\"InvalidEscape\", \"A trailing backslash escapes nothing\");\n if (next !== \"\\n\") {\n word.push(next);\n plain = false;\n }\n i++;\n } else if (char === \"'\" || char === \"\\\"\") {\n quote = char;\n quotePart = part;\n word.push(\"\");\n plain = false;\n } else {\n const unsupported = unsupportedSyntax(char, next, word.length === 0);\n if (unsupported !== undefined) return error(\"UnsupportedSyntax\", unsupported);\n if (char === \"{\") {\n braceDepth++;\n } else if (char === \"}\") {\n if (braceDepth > 0) braceDepth--;\n } else if (braceDepth > 0 && (char === \",\" || char === \".\" && next === \".\")) {\n return error(\"UnsupportedSyntax\", \"Brace expansion needs a shell\");\n } else if (char === \"=\" && words.length === 0 && plain && assignmentName.test(word.join(\"\"))) {\n return error(\"UnsupportedSyntax\", \"A variable assignment needs a shell\");\n }\n word.push(char);\n }\n }\n return undefined;\n };\n for (; part < texts.length; part++) {\n const failure = scan(texts[part]);\n if (failure !== undefined) return failure;\n if (part === values.length) break;\n const expression = values[part];\n if (Array.isArray(expression)) {\n // An array must stand alone: nothing may touch it on either side.\n const after = texts[part + 1][0];\n if (word.length > 0 || (after === undefined ? part + 1 < values.length : !isBlank(after))) {\n return error(\"UnsupportedSyntax\", \"An interpolated array must be a separate argument\");\n }\n for (const item of expression) words.push(toWord(item));\n } else {\n word.push(toWord(expression));\n plain = false;\n }\n }\n if (quote !== undefined) return error(\"UnterminatedQuote\", \"The quote is not closed\", quotePart);\n endWord();\n return Result.succeed(words);\n};\n//# sourceMappingURL=CommandLine.js.map",
|
|
38
|
+
"/**\n * Describes child processes before they are started.\n *\n * A `Command` stores the executable, arguments, environment, standard streams,\n * working directory, and other process options. Commands can also be piped\n * together. A command is an `Effect`; running it asks the\n * `ChildProcessSpawner` service to start the process and returns a\n * `ChildProcessHandle`.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Context from \"../Context.js\";\nimport * as Effectable from \"../Effectable.js\";\nimport { dual } from \"../Function.js\";\nimport * as Predicate from \"../Predicate.js\";\nimport * as Result from \"../Result.js\";\nimport { ChildProcessSpawner } from \"./ChildProcessSpawner.js\";\nimport * as CommandLine from \"./CommandLine.js\";\nconst TypeId = \"~effect/process/ChildProcess\";\n// =============================================================================\n// Constructors\n// =============================================================================\nconst Proto = {\n ... /*#__PURE__*/Effectable.Prototype({\n label: \"Command\",\n evaluate(fiber) {\n return Context.getUnsafe(fiber.context, ChildProcessSpawner).spawn(this);\n }\n }),\n [TypeId]: TypeId\n};\n/**\n * Checks whether a value is a `Command`.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isCommand = u => Predicate.hasProperty(u, TypeId);\n/**\n * Checks whether a command is a `StandardCommand`.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isStandardCommand = command => command._tag === \"StandardCommand\";\n/**\n * Checks whether a command is a `PipedCommand`.\n *\n * @stability unstable\n * @category guards\n * @since 4.0.0\n */\nexport const isPipedCommand = command => command._tag === \"PipedCommand\";\nconst makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto), {\n _tag: \"StandardCommand\",\n command,\n args,\n options\n});\nconst makePipedCommand = (left, right, options = {}) => Object.assign(Object.create(Proto), {\n _tag: \"PipedCommand\",\n left,\n right,\n options\n});\n/**\n * Create a command from a template literal, options + template, or array form.\n *\n * **Details**\n *\n * This function supports three calling conventions:\n * 1. Template literal: `make\\`npm run build\\``\n * 2. Options + template literal: `make({ cwd: \"/app\" })\\`npm run build\\``\n * 3. Array form: `make(\"npm\", [\"run\", \"build\"], options?)`\n *\n * Templates are split with `CommandLine.template`: quotes group words, each\n * `${}` value is one literal argument, and an argument that contains a\n * `Redacted` value stays `Redacted`. Arguments in the array form can be\n * `Redacted` too.\n *\n * With the `shell` option, the template text is the shell script and is kept\n * as written.\n *\n * **Gotchas**\n *\n * - A template is parsed when `make` is called. Shell syntax such as `|`,\n * `$HOME`, `*` or `~` throws a `CommandLine.CommandLineError`: quote it, or\n * pass the value with `${}`.\n * - A template with the `shell` option cannot contain `${}` values, because\n * their quoting depends on the shell. Build the script with\n * `CommandLine.quote` and pass it as a string.\n * - The program name, the first word, cannot be `Redacted`.\n * - A NUL character in the command, an argument or an `env` value fails with\n * a `BadArgument` error when the command is spawned.\n *\n * **Example** (Creating commands)\n *\n * ```ts import.meta.vitest\n * import { ChildProcess } from \"effect/process\"\n *\n * // Template literal form; quotes group words\n * const cmd1 = ChildProcess.make`echo \"hello world\"`\n *\n * // With options\n * const cmd2 = ChildProcess.make({ cwd: \"/tmp\" })`ls -la`\n *\n * // Array form\n * const cmd3 = ChildProcess.make(\"git\", [\"status\"])\n *\n * const result = [cmd1.args[0], cmd2.options.cwd, cmd3.args[0]] // => [\"hello world\", \"/tmp\", \"status\"]\n * ```\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = function make(...args) {\n // Template literal form: make`command`\n if (isTemplateString(args[0])) {\n const [templates, ...expressions] = args;\n const [command, cmdArgs] = parseTemplate(templates, expressions);\n return makeStandardCommand(command, cmdArgs, {});\n }\n // Options form: make({ cwd: \"/tmp\" })`command`\n if (typeof args[0] === \"object\" && !Array.isArray(args[0]) && !isTemplateString(args[0])) {\n const options = args[0];\n return function (templates, ...expressions) {\n if (options.shell !== undefined && options.shell !== false) {\n return makeStandardCommand(shellScript(templates, expressions), [], options);\n }\n const [command, cmdArgs] = parseTemplate(templates, expressions);\n return makeStandardCommand(command, cmdArgs, options);\n };\n }\n // Standard form without arguments: make(\"command\", options?)\n if (typeof args[0] === \"string\" && !Array.isArray(args[1])) {\n const [command, options = {}] = args;\n return makeStandardCommand(command, [], options);\n }\n // Standard form with arguments: make(\"command\", [\"arg1\", \"arg2\"], options?)\n const [command, cmdArgs = [], options = {}] = args;\n return makeStandardCommand(command, cmdArgs, options);\n};\n/**\n * Pipes the output of one command to the input of another.\n *\n * **Details**\n *\n * By default, pipes `stdout` from the source to `stdin` of the destination.\n * Use the `options` parameter to customize which streams are connected.\n *\n * **Example** (Piping command output)\n *\n * ```ts import.meta.vitest\n * import { ChildProcess } from \"effect/process\"\n *\n * // Pipe stdout (default)\n * const pipeline1 = ChildProcess.make`cat file.txt`.pipe(\n * ChildProcess.pipeTo(ChildProcess.make`grep pattern`)\n * )\n *\n * // Pipe stderr instead of stdout\n * const pipeline2 = ChildProcess.make`my-program`.pipe(\n * ChildProcess.pipeTo(ChildProcess.make`grep error`, { from: \"stderr\" })\n * )\n *\n * // Pipe combined stdout and stderr\n * const pipeline3 = ChildProcess.make`my-program`.pipe(\n * ChildProcess.pipeTo(ChildProcess.make`tee output.log`, { from: \"all\" })\n * )\n *\n * const result = [pipeline1._tag, pipeline2.options.from, pipeline3.options.from]\n * result // => [\"PipedCommand\", \"stderr\", \"all\"]\n * ```\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const pipeTo = /*#__PURE__*/dual(args => isCommand(args[0]) && isCommand(args[1]), (self, that, options) => makePipedCommand(self, that, options ?? {}));\n/**\n * Prepends another command to a command.\n *\n * **Details**\n *\n * For pipelines, only the leftmost command is prefixed.\n *\n * **Example** (Prefixing commands)\n *\n * ```ts import.meta.vitest\n * import { ChildProcess } from \"effect/process\"\n *\n * const command = ChildProcess.make`echo foo`\n *\n * const prefixed = command.pipe(\n * ChildProcess.prefix`time`\n * )\n *\n * // now prefixed will execute `time echo \"foo\"`\n * const result = prefixed._tag === \"StandardCommand\" ? `${prefixed.command} ${prefixed.args[0]}` : prefixed._tag\n * result // => \"time echo\"\n * ```\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const prefix = function prefix(...args) {\n if (isCommand(args[0]) && args.length > 1) {\n const [self, ...rest] = args;\n const prefixSpec = parsePrefixArgs(rest);\n return applyPrefix(self, prefixSpec);\n }\n const prefixSpec = parsePrefixArgs(args);\n return self => applyPrefix(self, prefixSpec);\n};\nconst parsePrefixArgs = args => {\n if (isTemplateString(args[0])) {\n const [templates, ...expressions] = args;\n const [command, cmdArgs] = parseTemplate(templates, expressions);\n return {\n command,\n args: cmdArgs\n };\n }\n const [command, cmdArgs = []] = args;\n return {\n command,\n args: cmdArgs\n };\n};\nconst applyPrefix = (self, prefixSpec) => {\n switch (self._tag) {\n case \"StandardCommand\":\n {\n return makeStandardCommand(prefixSpec.command, [...prefixSpec.args, self.command, ...self.args], self.options);\n }\n case \"PipedCommand\":\n {\n return makePipedCommand(applyPrefix(self.left, prefixSpec), self.right, self.options);\n }\n }\n};\n/**\n * Sets the current working directory for a command.\n *\n * **Details**\n *\n * For pipelines, applies to each command in the pipeline.\n *\n * **Example** (Setting command working directories)\n *\n * ```ts import.meta.vitest\n * import { ChildProcess } from \"effect/process\"\n *\n * const cmd = ChildProcess.make`ls -la`.pipe(\n * ChildProcess.setCwd(\"/tmp\")\n * )\n * const result = cmd._tag === \"StandardCommand\" && cmd.options.cwd // => \"/tmp\"\n * ```\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const setCwd = /*#__PURE__*/dual(2, (self, cwd) => {\n switch (self._tag) {\n case \"StandardCommand\":\n {\n return makeStandardCommand(self.command, self.args, {\n ...self.options,\n cwd\n });\n }\n case \"PipedCommand\":\n {\n return makePipedCommand(setCwd(self.left, cwd), setCwd(self.right, cwd), self.options);\n }\n }\n});\n/**\n * Adds environment variables to a command, merging them with any existing\n * command environment and overriding duplicate keys.\n *\n * **Details**\n *\n * For pipelines, applies to each command in the pipeline.\n *\n * **Example** (Setting command environment variables)\n *\n * ```ts import.meta.vitest\n * import { ChildProcess } from \"effect/process\"\n *\n * const cmd = ChildProcess.make`node script.js`.pipe(\n * ChildProcess.setEnv({ NODE_ENV: \"test\" })\n * )\n * const result = cmd._tag === \"StandardCommand\" && cmd.options.env?.NODE_ENV // => \"test\"\n * ```\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const setEnv = /*#__PURE__*/dual(2, (self, env) => {\n switch (self._tag) {\n case \"StandardCommand\":\n {\n const nextEnv = self.options.env === undefined ? env : {\n ...self.options.env,\n ...env\n };\n return makeStandardCommand(self.command, self.args, {\n ...self.options,\n env: nextEnv\n });\n }\n case \"PipedCommand\":\n {\n return makePipedCommand(setEnv(self.left, env), setEnv(self.right, env), self.options);\n }\n }\n});\nconst isTemplateString = u => Array.isArray(u) && \"raw\" in u && Array.isArray(u.raw);\n// =============================================================================\n// Utilities\n// =============================================================================\n/**\n * Parses an fd name like \"fd3\" to its numeric index.\n * Returns undefined if the name is invalid.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const parseFdName = name => {\n const match = /^fd(\\d+)$/.exec(name);\n if (match === null) return undefined;\n const fd = parseInt(match[1], 10);\n return fd >= 3 ? fd : undefined;\n};\n/**\n * Create an fd name from its numeric index.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const fdName = fd => `fd${fd}`;\n// =============================================================================\n// Template Parsing\n// =============================================================================\nconst parseTemplate = (templates, expressions) => {\n const [program = \"\", ...args] = Result.getOrThrow(CommandLine.template(templates, ...expressions));\n if (typeof program !== \"string\") {\n throw new CommandLine.CommandLineError({\n reason: \"InvalidArgument\",\n message: \"The program name of a command cannot be Redacted\"\n });\n }\n return [program, args];\n};\nconst shellScript = (templates, expressions) => {\n if (expressions.length > 0) {\n throw new CommandLine.CommandLineError({\n reason: \"UnsupportedSyntax\",\n message: \"A shell template cannot interpolate values; build the script with CommandLine.quote\"\n });\n }\n const script = templates[0];\n if (script === undefined) {\n throw new CommandLine.CommandLineError({\n reason: \"InvalidEscape\",\n message: \"Template part 0 contains an invalid escape sequence\"\n });\n }\n return script;\n};\n//# sourceMappingURL=ChildProcess.js.map",
|
|
39
|
+
"import * as Deferred from \"effect/Deferred\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport * as Path from \"effect/Path\";\nimport * as PlatformError from \"effect/PlatformError\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as ChildProcess from \"effect/process/ChildProcess\";\nimport { ChildProcessSpawner, ExitCode, make as makeSpawner, makeHandle, ProcessId } from \"effect/process/ChildProcessSpawner\";\nimport * as CommandLine from \"effect/process/CommandLine\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Sink from \"effect/Sink\";\nimport * as Stream from \"effect/Stream\";\nimport * as NodeChildProcess from \"node:child_process\";\nimport { PassThrough } from \"node:stream\";\nimport { buildSpawnOptions } from \"./internal/nodeChildProcessSpawner.js\";\nimport { handleErrnoException } from \"./internal/utils.js\";\nimport * as NodeSink from \"./NodeSink.js\";\nimport * as NodeStream from \"./NodeStream.js\";\nconst toError = error => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));\nconst toPlatformError = (method, error, command) => {\n const {\n commands\n } = flattenCommand(command);\n const format = globalThis.process.platform === \"win32\" ? \"windows\" : \"posix\";\n const commandStr = commands.map(cmd => CommandLine.display([cmd.command, ...cmd.args], {\n format\n })).join(\" | \");\n return handleErrnoException(\"ChildProcess\", method)(error, [commandStr]);\n};\nconst unwrap = value => Redacted.isRedacted(value) ? Redacted.value(value) : value;\n// Node's own NUL check throws an error that includes the value, so NUL is\n// rejected here to keep Redacted values out of errors.\nconst findNulCharacter = command => {\n if (command.command.includes(\"\\0\")) return \"The command contains a NUL character\";\n const index = command.args.findIndex(arg => unwrap(arg).includes(\"\\0\"));\n if (index !== -1) return `Argument ${index + 1} contains a NUL character`;\n for (const [name, value] of Object.entries(command.options.env ?? {})) {\n if (value !== undefined && unwrap(value).includes(\"\\0\")) {\n return `The environment variable ${name} contains a NUL character`;\n }\n }\n return undefined;\n};\nconst processGroupGraceMillis = 1_000;\nconst processGroupPollIntervalMillis = 10;\n// Buffered writes can fail after the sink has been interrupted and removed its\n// error listener. Keep a fallback until close, without replacing the sink\n// listener that propagates errors while it is active.\nconst handleInputErrors = writable => {\n const onError = () => {};\n writable.on(\"error\", onError);\n writable.once(\"close\", () => writable.off(\"error\", onError));\n};\n/** Node has recorded the leader's exit, after which its PID may be reused by an unrelated process. */\nconst hasExited = childProcess => childProcess.exitCode !== null || childProcess.signalCode !== null;\n/**\n * A non-detached leader shares its parent's process group, so once it has\n * exited there is no group of its own left to signal or poll.\n */\nconst ownsProcessGroup = (command, childProcess) => command.options.detached !== false || !hasExited(childProcess);\n/**\n * The process group exists but has no member that can be signalled, such as\n * on macOS when its remaining members are zombies.\n */\nconst isUnsignallableProcessGroup = error => error?.code === \"EPERM\";\n/** The leader has not exited, or a member of its process group still exists. */\nconst isProcessAlive = (command, childProcess) => {\n if (!hasExited(childProcess)) {\n return true;\n }\n if (globalThis.process.platform === \"win32\" || !ownsProcessGroup(command, childProcess)) {\n return false;\n }\n try {\n globalThis.process.kill(-childProcess.pid, 0);\n return true;\n } catch (error) {\n return isUnsignallableProcessGroup(error);\n }\n};\nconst taskkill = (childProcess, onExit = () => {}) => {\n if (hasExited(childProcess)) {\n onExit(null);\n return;\n }\n NodeChildProcess.execFile(\"taskkill\", [\"/pid\", String(childProcess.pid), \"/T\", \"/F\"], {\n windowsHide: true\n }, onExit);\n};\nconst make = /*#__PURE__*/Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const resolveWorkingDirectory = Effect.fnUntraced(function* (options) {\n if (Predicate.isUndefined(options.cwd)) return undefined;\n // Validate that the specified directory is accessible\n yield* fs.access(options.cwd);\n return path.resolve(options.cwd);\n });\n const resolveEnvironment = options => {\n if (options.env === undefined) return undefined;\n const env = options.extendEnv === true ? {\n ...globalThis.process.env\n } : {};\n for (const [key, value] of Object.entries(options.env)) {\n if (value === undefined) delete env[key];else env[key] = unwrap(value);\n }\n return env;\n };\n const inputToStdioOption = input => Stream.isStream(input) ? \"pipe\" : input;\n const outputToStdioOption = input => Sink.isSink(input) ? \"pipe\" : input;\n const resolveStdinOption = options => {\n const defaultConfig = {\n stream: \"pipe\",\n encoding: \"utf-8\",\n endOnDone: true\n };\n if (Predicate.isUndefined(options.stdin)) {\n return defaultConfig;\n }\n if (typeof options.stdin === \"string\") {\n return {\n ...defaultConfig,\n stream: options.stdin\n };\n }\n if (Stream.isStream(options.stdin)) {\n return {\n ...defaultConfig,\n stream: options.stdin\n };\n }\n return {\n stream: options.stdin.stream,\n encoding: options.stdin.encoding ?? defaultConfig.encoding,\n endOnDone: options.stdin.endOnDone ?? defaultConfig.endOnDone\n };\n };\n const resolveOutputOption = (options, streamName) => {\n const option = options[streamName];\n if (Predicate.isUndefined(option)) {\n return {\n stream: \"pipe\"\n };\n }\n if (typeof option === \"string\") {\n return {\n stream: option\n };\n }\n if (Sink.isSink(option)) {\n return {\n stream: option\n };\n }\n return {\n stream: option.stream\n };\n };\n const resolveAdditionalFds = options => {\n if (Predicate.isUndefined(options.additionalFds)) {\n return [];\n }\n const result = [];\n for (const [name, config] of Object.entries(options.additionalFds)) {\n const fd = ChildProcess.parseFdName(name);\n if (Predicate.isNotUndefined(fd)) {\n result.push({\n fd,\n config\n });\n }\n }\n // Sort by fd number to ensure correct ordering\n return result.sort((a, b) => a.fd - b.fd);\n };\n const buildStdioArray = (stdinConfig, stdoutConfig, stderrConfig, additionalFds) => {\n const stdio = [inputToStdioOption(stdinConfig.stream), outputToStdioOption(stdoutConfig.stream), outputToStdioOption(stderrConfig.stream)];\n if (additionalFds.length === 0) {\n return stdio;\n }\n // Find the maximum fd number to size the array correctly\n const maxFd = additionalFds.reduce((max, {\n fd\n }) => Math.max(max, fd), 2);\n // Fill gaps with \"ignore\"\n for (let i = 3; i <= maxFd; i++) {\n stdio[i] = \"ignore\";\n }\n // Set up additional fds as \"pipe\"\n for (const {\n fd\n } of additionalFds) {\n stdio[fd] = \"pipe\";\n }\n return stdio;\n };\n // Runs a user-provided input stream into its sink, recording a failure of\n // the source stream so that it can be surfaced by the process exit code\n const runInputStream = (stream, sink, inputFailure) => Effect.forkScoped(Stream.run(Stream.tapError(stream, error => Deferred.fail(inputFailure, error)), sink));\n const setupAdditionalFds = Effect.fnUntraced(function* (command, childProcess, additionalFds, inputFailure) {\n if (additionalFds.length === 0) {\n return {\n getInputFd: () => Sink.drain,\n getOutputFd: () => Stream.empty\n };\n }\n const inputSinks = new Map();\n const outputStreams = new Map();\n const setupInput = (fd, nodeStream, stream) => Effect.suspend(() => {\n let sink = Sink.drain;\n if (nodeStream && \"write\" in nodeStream) {\n handleInputErrors(nodeStream);\n sink = NodeSink.fromWritable({\n evaluate: () => nodeStream,\n onError: error => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)\n });\n }\n if (stream) {\n return Effect.map(runInputStream(stream, sink, inputFailure), () => {\n inputSinks.set(fd, sink);\n });\n }\n inputSinks.set(fd, sink);\n return Effect.void;\n });\n const setupOutput = (fd, nodeStream, sink) => {\n let stream = Stream.empty;\n if (nodeStream && \"read\" in nodeStream) {\n const passThrough = new PassThrough();\n // Retain errors raised before anyone reads, e.g. a failed write on a\n // duplex fd, so they neither go uncaught nor leave later readers hanging\n let error = undefined;\n passThrough.on(\"error\", cause => {\n error ??= cause;\n });\n nodeStream.on(\"error\", cause => passThrough.destroy(cause));\n nodeStream.pipe(passThrough);\n const onError = cause => toPlatformError(`fromReadable(fd${fd})`, toError(cause), command);\n stream = Stream.suspend(() => error === undefined ? NodeStream.fromReadable({\n evaluate: () => passThrough,\n onError\n }) : Stream.fail(onError(error)));\n }\n if (sink) {\n stream = Stream.transduce(stream, sink);\n }\n outputStreams.set(fd, stream);\n };\n for (const {\n config,\n fd\n } of additionalFds) {\n const nodeStream = childProcess.stdio[fd];\n switch (config.type) {\n case \"input\":\n {\n yield* setupInput(fd, nodeStream, config.stream);\n break;\n }\n case \"output\":\n {\n setupOutput(fd, nodeStream, config.sink);\n break;\n }\n case \"duplex\":\n {\n // Keep writing possible after the child closes its write side.\n if (nodeStream && \"allowHalfOpen\" in nodeStream) {\n nodeStream.allowHalfOpen = true;\n }\n setupOutput(fd, nodeStream, config.sink);\n yield* setupInput(fd, nodeStream, config.stream);\n break;\n }\n }\n }\n return {\n getInputFd: fd => inputSinks.get(fd) ?? Sink.drain,\n getOutputFd: fd => outputStreams.get(fd) ?? Stream.empty\n };\n });\n const setupChildStdin = (command, childProcess, config, inputFailure) => Effect.suspend(() => {\n // If the child process has a standard input stream, connect it to the\n // sink that will attached to the process handle\n let sink = Sink.drain;\n if (Predicate.isNotNull(childProcess.stdin)) {\n handleInputErrors(childProcess.stdin);\n sink = NodeSink.fromWritable({\n evaluate: () => childProcess.stdin,\n onError: error => toPlatformError(\"fromWritable(stdin)\", toError(error), command),\n endOnDone: config.endOnDone,\n encoding: config.encoding\n });\n }\n // If the user provided a `Stream`, run it into the stdin sink\n if (Stream.isStream(config.stream)) {\n return Effect.as(runInputStream(config.stream, sink, inputFailure), sink);\n }\n return Effect.succeed(sink);\n });\n const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {\n let stdout = childProcess.stdout ? (() => {\n const passThrough = new PassThrough();\n childProcess.stdout.on(\"error\", error => passThrough.destroy(error));\n childProcess.stdout.pipe(passThrough);\n return NodeStream.fromReadable({\n evaluate: () => passThrough,\n onError: error => toPlatformError(\"fromReadable(stdout)\", toError(error), command)\n });\n })() : Stream.empty;\n let stderr = childProcess.stderr ? (() => {\n const passThrough = new PassThrough();\n childProcess.stderr.on(\"error\", error => passThrough.destroy(error));\n childProcess.stderr.pipe(passThrough);\n return NodeStream.fromReadable({\n evaluate: () => passThrough,\n onError: error => toPlatformError(\"fromReadable(stderr)\", toError(error), command)\n });\n })() : Stream.empty;\n if (Sink.isSink(stdoutConfig.stream)) {\n stdout = Stream.transduce(stdout, stdoutConfig.stream);\n }\n if (Sink.isSink(stderrConfig.stream)) {\n stderr = Stream.transduce(stderr, stderrConfig.stream);\n }\n const all = Stream.merge(stdout, stderr);\n return {\n stdout,\n stderr,\n all\n };\n };\n const spawn = (command, spawnOptions) => Effect.callback(resume => {\n const deferred = Deferred.makeUnsafe();\n const handle = NodeChildProcess.spawn(command.command, command.args.map(unwrap), spawnOptions);\n handle.on(\"error\", error => {\n // Node copies the arguments into `spawnargs`.\n if (command.args.some(Redacted.isRedacted)) {\n Object.assign(error, {\n spawnargs: [command.command, ...command.args.map(arg => Redacted.isRedacted(arg) ? \"<redacted>\" : arg)]\n });\n }\n resume(Effect.fail(toPlatformError(\"spawn\", error, command)));\n });\n handle.on(\"exit\", (...args) => {\n Deferred.doneUnsafe(deferred, Exit.succeed(args));\n });\n handle.on(\"spawn\", () => {\n resume(Effect.succeed([handle, deferred]));\n });\n return Effect.sync(() => {\n handle.kill(\"SIGTERM\");\n });\n });\n const killProcessGroup = (command, childProcess, signal) => {\n if (globalThis.process.platform === \"win32\") {\n return Effect.callback(resume => {\n taskkill(childProcess, error => {\n if (error) {\n resume(Effect.fail(toPlatformError(\"kill\", toError(error), command)));\n } else {\n resume(Effect.void);\n }\n });\n });\n }\n return Effect.try({\n try: () => {\n globalThis.process.kill(-childProcess.pid, signal);\n },\n catch: error => toPlatformError(\"kill\", toError(error), command)\n });\n };\n const killProcessGroupOnExit = (childProcess, signal) => {\n if (globalThis.process.platform === \"win32\") {\n // ignore errors during best-effort cleanup\n taskkill(childProcess);\n return;\n }\n try {\n globalThis.process.kill(-childProcess.pid, signal);\n } catch {\n // ignore errors during best-effort cleanup\n }\n };\n const killProcess = (command, childProcess, signal) => Effect.suspend(() => {\n const killed = childProcess.kill(signal);\n if (!killed) {\n const error = new globalThis.Error(\"Failed to kill child process\");\n return Effect.fail(toPlatformError(\"kill\", error, command));\n }\n return Effect.void;\n });\n /** Waits for the leader and its process group, bounded by native time. */\n const awaitProcessExit = (command, childProcess, timeoutMillis) => Effect.callback(resume => {\n const deadline = Date.now() + timeoutMillis;\n let timer;\n const stop = () => {\n clearTimeout(timer);\n childProcess.removeListener(\"exit\", poll);\n };\n const poll = () => {\n clearTimeout(timer);\n if (Date.now() >= deadline || !isProcessAlive(command, childProcess)) {\n stop();\n resume(Effect.void);\n return;\n }\n timer = setTimeout(poll, processGroupPollIntervalMillis);\n };\n childProcess.on(\"exit\", poll);\n poll();\n return Effect.sync(stop);\n });\n const terminateProcessGroup = Effect.fnUntraced(function* (command, childProcess, exitSignal, options) {\n const signalGroup = signal => ownsProcessGroup(command, childProcess) ? killProcessGroup(command, childProcess, signal).pipe(Effect.catch(error =>\n // Only zombies remain in the exited leader's group, so nothing is left to signal.\n hasExited(childProcess) && isUnsignallableProcessGroup(error.cause) ? Effect.void : killProcess(command, childProcess, signal))) : killProcess(command, childProcess, signal);\n yield* signalGroup(options?.killSignal ?? \"SIGTERM\");\n if (Predicate.isUndefined(options?.forceKillAfter)) {\n yield* Deferred.await(exitSignal);\n yield* awaitProcessExit(command, childProcess, processGroupGraceMillis);\n } else {\n yield* awaitProcessExit(command, childProcess, Duration.toMillis(options.forceKillAfter));\n if (isProcessAlive(command, childProcess)) {\n yield* signalGroup(\"SIGKILL\");\n yield* awaitProcessExit(command, childProcess, processGroupGraceMillis);\n }\n }\n yield* Deferred.await(exitSignal);\n });\n /**\n * Get the appropriate source stream from a process handle based on the\n * `from` pipe option.\n */\n const getSourceStream = (handle, from) => {\n const fromOption = from ?? \"stdout\";\n switch (fromOption) {\n case \"stdout\":\n return handle.stdout;\n case \"stderr\":\n return handle.stderr;\n case \"all\":\n return handle.all;\n default:\n {\n // Handle fd3, fd4, etc.\n const fd = ChildProcess.parseFdName(fromOption);\n if (Predicate.isNotUndefined(fd)) {\n return handle.getOutputFd(fd);\n }\n // Fallback to stdout for invalid fd names\n return handle.stdout;\n }\n }\n };\n const spawnCommand = Effect.fnUntraced(function* (cmd) {\n switch (cmd._tag) {\n case \"StandardCommand\":\n {\n if (cmd.options.shell !== undefined && cmd.options.shell !== false && cmd.args.length > 0) {\n return yield* Effect.fail(PlatformError.badArgument({\n module: \"ChildProcess\",\n method: \"spawn\",\n description: \"The shell option cannot be combined with arguments; pass the whole script as the command\"\n }));\n }\n const nulCharacter = findNulCharacter(cmd);\n if (nulCharacter !== undefined) {\n return yield* Effect.fail(PlatformError.badArgument({\n module: \"ChildProcess\",\n method: \"spawn\",\n description: nulCharacter\n }));\n }\n const stdinConfig = resolveStdinOption(cmd.options);\n const stdoutConfig = resolveOutputOption(cmd.options, \"stdout\");\n const stderrConfig = resolveOutputOption(cmd.options, \"stderr\");\n const resolvedAdditionalFds = resolveAdditionalFds(cmd.options);\n let isReferenced = true;\n const cwd = yield* resolveWorkingDirectory(cmd.options);\n const env = resolveEnvironment(cmd.options);\n const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);\n const [childProcess, exitSignal] = yield* Effect.acquireRelease(spawn(cmd, buildSpawnOptions(cmd.options, {\n cwd,\n env,\n stdio\n }, process.platform)), Effect.fnUntraced(function* ([childProcess, exitSignal]) {\n const exited = yield* Deferred.isDone(exitSignal);\n if (exited) {\n const [code] = yield* Deferred.await(exitSignal);\n if (code !== 0 && Predicate.isNotNull(code)) {\n yield* Effect.ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));\n } else if (isReferenced && process.platform !== \"win32\" && cmd.options.detached !== false) {\n yield* Effect.ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));\n }\n return;\n }\n if (!isReferenced) {\n return;\n }\n yield* Effect.ignore(terminateProcessGroup(cmd, childProcess, exitSignal, cmd.options));\n }));\n const pid = ProcessId(childProcess.pid);\n // A non-detached child leaves no process group of its own to clean up.\n if (cmd.options.detached !== false) {\n childProcess.on(\"exit\", code => {\n if (code !== 0 && Predicate.isNotNull(code)) {\n killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? \"SIGTERM\");\n }\n });\n }\n const reref = Effect.sync(() => {\n if (!isReferenced) {\n childProcess.ref();\n isReferenced = true;\n }\n });\n const unref = Effect.sync(() => {\n if (isReferenced) {\n childProcess.unref();\n isReferenced = false;\n }\n return reref;\n });\n const inputFailure = Deferred.makeUnsafe();\n const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig, inputFailure);\n const {\n all,\n stderr,\n stdout\n } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig);\n const {\n getInputFd,\n getOutputFd\n } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds, inputFailure);\n const isRunning = Effect.map(Deferred.isDone(exitSignal), done => !done);\n // A failed input stream truncates the input of the child process, so\n // its failure takes precedence over the exit status and is surfaced\n // without waiting for the child process to exit\n const exitCode = Effect.flatMap(Effect.raceFirst(Deferred.await(exitSignal), Deferred.await(inputFailure)), ([code, signal]) => {\n if (Deferred.isDoneUnsafe(inputFailure)) {\n return Deferred.await(inputFailure);\n }\n if (Predicate.isNotNull(code)) {\n return Effect.succeed(ExitCode(code));\n }\n // If code is `null`, then `signal` must be defined. See the NodeJS\n // documentation for the `\"exit\"` event on a `child_process`.\n // https://nodejs.org/api/child_process.html#child_process_event_exit\n const error = new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`);\n return Effect.fail(toPlatformError(\"exitCode\", error, cmd));\n });\n const kill = options => terminateProcessGroup(cmd, childProcess, exitSignal, options);\n return makeHandle({\n pid,\n exitCode,\n isRunning,\n kill,\n stdin,\n stdout,\n stderr,\n all,\n getInputFd,\n getOutputFd,\n unref\n });\n }\n case \"PipedCommand\":\n {\n const {\n commands,\n pipeOptions\n } = flattenCommand(cmd);\n const [root, ...pipeline] = commands;\n const handles = [yield* spawnCommand(root)];\n for (let i = 0; i < pipeline.length; i++) {\n const command = pipeline[i];\n const options = pipeOptions[i] ?? {};\n const stdinConfig = resolveStdinOption(command.options);\n // Get the appropriate stream from the source based on `from` option\n const sourceStream = Stream.unwrap(Effect.succeed(getSourceStream(handles[handles.length - 1], options.from)));\n // Determine where to pipe: stdin or custom fd\n const toOption = options.to ?? \"stdin\";\n if (toOption === \"stdin\") {\n // Pipe to stdin (default behavior)\n handles.push(yield* spawnCommand(ChildProcess.make(command.command, command.args, {\n ...command.options,\n stdin: {\n ...stdinConfig,\n stream: sourceStream\n }\n })));\n } else {\n // Pipe to custom fd (fd3, fd4, etc.)\n const fd = ChildProcess.parseFdName(toOption);\n if (Predicate.isNotUndefined(fd)) {\n const fdName = ChildProcess.fdName(fd);\n const existingFds = command.options.additionalFds ?? {};\n const existingFd = existingFds[fdName];\n const fdConfig = existingFd?.type === \"duplex\" ? {\n ...existingFd,\n stream: sourceStream\n } : {\n type: \"input\",\n stream: sourceStream\n };\n handles.push(yield* spawnCommand(ChildProcess.make(command.command, command.args, {\n ...command.options,\n additionalFds: {\n ...existingFds,\n [fdName]: fdConfig\n }\n })));\n } else {\n // Invalid fd name, fall back to stdin\n handles.push(yield* spawnCommand(ChildProcess.make(command.command, command.args, {\n ...command.options,\n stdin: {\n ...stdinConfig,\n stream: sourceStream\n }\n })));\n }\n }\n }\n const handle = handles[handles.length - 1];\n const kill = options => Effect.forEach([...handles].reverse(), handle => Effect.ignore(handle.kill(options)), {\n discard: true\n });\n const unref = Effect.gen(function* () {\n const rerefs = [];\n for (const handle of handles) {\n rerefs.push(yield* handle.unref);\n }\n return Effect.forEach([...rerefs].reverse(), reref => reref, {\n discard: true\n });\n });\n return makeHandle({\n pid: handle.pid,\n exitCode: handle.exitCode,\n isRunning: handle.isRunning,\n kill,\n stdin: handles[0].stdin,\n stdout: handle.stdout,\n stderr: handle.stderr,\n all: handle.all,\n getInputFd: handle.getInputFd,\n getOutputFd: handle.getOutputFd,\n unref\n });\n }\n }\n });\n return makeSpawner(spawnCommand);\n});\n/**\n * Layer that provides the `NodeChildProcessSpawner` implementation.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.effect(ChildProcessSpawner, make);\n/**\n * Flattens a `Command` into an array of `StandardCommand`s along with pipe\n * options for each connection.\n *\n * @stability unstable\n * @category transforming\n * @since 4.0.0\n */\nexport const flattenCommand = command => {\n const commands = [];\n const pipeOptions = [];\n const flatten = cmd => {\n switch (cmd._tag) {\n case \"StandardCommand\":\n {\n commands.push(cmd);\n break;\n }\n case \"PipedCommand\":\n {\n // Recursively flatten left side first\n flatten(cmd.left);\n // Store the pipe options for this connection\n pipeOptions.push(cmd.options);\n // Then flatten right side\n flatten(cmd.right);\n break;\n }\n }\n };\n flatten(command);\n // The commands array is guaranteed to be non-empty since we always have at\n // least one command in the input. We validate this at runtime and return a\n // properly typed tuple.\n if (commands.length === 0) {\n // This should never happen given a valid Command input\n throw new Error(\"flattenCommand produced empty commands array\");\n }\n const [first, ...rest] = commands;\n const nonEmptyCommands = [first, ...rest];\n return {\n commands: nonEmptyCommands,\n pipeOptions\n };\n};\n//# sourceMappingURL=NodeChildProcessSpawner.js.map",
|
|
40
|
+
"export const buildSpawnOptions = (options, base, platform) => {\n const detached = options.detached ?? platform !== \"win32\";\n return {\n ...base,\n detached,\n shell: options.shell,\n windowsHide: options.windowsHide ?? !detached\n };\n};\n//# sourceMappingURL=nodeChildProcessSpawner.js.map",
|
|
41
|
+
"import * as PlatformError from \"effect/PlatformError\";\n/** @internal */\nexport const handleErrnoException = (module, method) => (err, [path]) => {\n let reason = \"Unknown\";\n switch (err.code) {\n case \"ENOENT\":\n reason = \"NotFound\";\n break;\n case \"EACCES\":\n case \"EPERM\":\n reason = \"PermissionDenied\";\n break;\n case \"EEXIST\":\n reason = \"AlreadyExists\";\n break;\n case \"EISDIR\":\n reason = \"BadResource\";\n break;\n case \"ENOTDIR\":\n reason = \"BadResource\";\n break;\n case \"EBUSY\":\n reason = \"Busy\";\n break;\n case \"ELOOP\":\n reason = \"BadResource\";\n break;\n }\n return PlatformError.systemError({\n _tag: reason,\n module,\n method,\n pathOrDescriptor: path,\n syscall: err.syscall,\n cause: err\n });\n};\n//# sourceMappingURL=utils.js.map",
|
|
42
|
+
"import * as Cause from \"effect/Cause\";\nimport * as Channel from \"effect/Channel\";\nimport * as Deferred from \"effect/Deferred\";\nimport * as Effect from \"effect/Effect\";\nimport { constVoid, identity } from \"effect/Function\";\nimport * as Pull from \"effect/Pull\";\nimport * as Sink from \"effect/Sink\";\nimport { finished } from \"node:stream\";\nimport { destroyStream } from \"./internal/stream.js\";\n/**\n * Creates a `Sink` that writes chunks to a Node writable stream, respecting\n * backpressure and mapping writable errors with `onError`. Unless `endOnDone`\n * is `false`, the writable is ended on completion and destroyed on upstream\n * failure or interruption.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromWritable = options => Sink.fromChannel(Channel.mapDone(fromWritableChannel(options), _ => [_]));\n/**\n * Creates a `Channel` that pulls chunks from upstream and writes them to a\n * Node writable stream, respecting backpressure. Unless `endOnDone` is\n * `false`, the writable is ended when upstream is done and destroyed on\n * upstream failure or interruption.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromWritableChannel = options => Channel.fromTransform(pull => {\n const writable = options.evaluate();\n const write = pullIntoWritable({\n ...options,\n writable,\n pull\n });\n return Effect.succeed(options.endOnDone === false ? write : Effect.onError(write, cause => Pull.isDoneCause(cause) ? Effect.void : releaseWritable(writable)));\n});\n// Destroy the writable and wait for destruction to settle, keeping any\n// destruction error handled.\nconst releaseWritable = writable => Effect.callback(resume => {\n const onDestroyed = () => resume(Effect.void);\n if (writable.closed) {\n // Destruction may be complete with its error still queued.\n const cleanup = finished(writable, {\n readable: false\n }, () => {\n cleanup();\n onDestroyed();\n });\n } else {\n destroyStream(writable, constVoid, onDestroyed);\n }\n});\n/**\n * Writes Effect chunks into a Node writable stream.\n *\n * **When to use**\n *\n * Use to implement custom Node stream adapters that already have an upstream\n * pull and need direct control over a writable stream.\n *\n * **Details**\n *\n * The loop waits for `drain` when needed, fails on writable errors, and ends\n * the writable on upstream completion unless `endOnDone` is `false`.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const pullIntoWritable = options => Effect.withFiber(fiber => {\n const dispatcher = fiber.currentDispatcher;\n const completion = Deferred.makeUnsafe();\n const failure = Deferred.makeUnsafe();\n const onError = error => Deferred.doneUnsafe(failure, Effect.failSync(() => options.onError(error)));\n let errorEmitted = false;\n const onStreamError = error => {\n errorEmitted = true;\n onError(error);\n };\n // finished() only reports once, so keep listening for errors from writes\n // made after the writable has finished.\n options.writable.on(\"error\", onStreamError);\n const cleanup = finished(options.writable, {\n readable: false\n }, error => {\n if (error) {\n onError(error);\n } else {\n Deferred.doneUnsafe(completion, Effect.void);\n }\n });\n return options.pull.pipe(Effect.flatMap(chunk => {\n let i = 0;\n return Effect.callback(resume => {\n let cancelled = false;\n // Let Node finish auto-destruction before attempting another write.\n const onFinish = () => dispatcher.scheduleTask(loop, 0);\n const loop = () => {\n options.writable.off(\"drain\", loop);\n options.writable.off(\"finish\", onFinish);\n for (; i < chunk.length;) {\n if (cancelled) {\n return;\n }\n const success = options.writable.write(chunk[i++], options.encoding, error => {\n if (!error) return;\n if (options.writable.closed) {\n // Closed streams can reject writes through the callback only;\n // there is no pending destruction to wait for.\n onError(error);\n } else {\n // Let Node initiate auto-destruction before failure cleanup\n // checks whether an error event is still pending.\n dispatcher.scheduleTask(() => onError(error), 0);\n }\n });\n if (!success) {\n if (!cancelled) {\n options.writable.once(\"drain\", loop);\n // A normally finished writable will never emit drain. Resume\n // the loop so any remaining writes can report their errors.\n options.writable.once(\"finish\", onFinish);\n }\n return;\n }\n }\n if (!cancelled) {\n resume(Effect.void);\n }\n };\n loop();\n return Effect.sync(() => {\n cancelled = true;\n options.writable.off(\"drain\", loop);\n options.writable.off(\"finish\", onFinish);\n });\n });\n }), Effect.forever({\n disableYield: true\n }), options.endOnDone !== false ? Pull.catchDone(_ => {\n options.writable.end();\n return Effect.andThen(Deferred.await(completion), Cause.done(_));\n }) : identity, Effect.raceFirst(Deferred.await(failure)), Effect.ensuring(Effect.sync(() => {\n cleanup();\n const removeErrorListener = () => {\n options.writable.off(\"error\", onStreamError);\n options.writable.off(\"error\", removeErrorListener);\n options.writable.off(\"close\", removeErrorListener);\n };\n if (options.writable.errored && !options.writable.closed && !errorEmitted) {\n // A write callback can fail before asynchronous _destroy completes.\n // Keep handling Node's pending error until it is emitted (or closed),\n // without delaying failure for callback-only errors on closed streams.\n options.writable.once(\"error\", removeErrorListener);\n options.writable.once(\"close\", removeErrorListener);\n } else {\n removeErrorListener();\n }\n })));\n});\n//# sourceMappingURL=NodeSink.js.map",
|
|
43
|
+
"// Keep teardown errors handled after removing the consumer's lifecycle listeners.\n// Node emits the destruction error (if any) only once _destroy has completed.\n// When `onDestroyed` is given, it is called once destruction has settled and\n// the wait keeps the event loop alive.\nexport const destroyStream = (stream, cleanup, onDestroyed) => {\n if (!(\"closed\" in stream)) {\n cleanup();\n onDestroyed?.();\n return;\n }\n const onDone = () => {\n clearImmediate(immediate);\n stream.off(\"error\", onDone);\n stream.off(\"close\", onDone);\n onDestroyed?.();\n };\n // With emitClose: false, successful destruction emits no event. Check the\n // public closed flag on a later turn, after any queued destruction error.\n // This also protects streams already closed but with an error still queued.\n const onClosed = () => {\n if (stream.closed) {\n onDone();\n } else {\n immediate = setImmediate(onClosed);\n if (!onDestroyed) immediate.unref();\n }\n };\n let immediate = setImmediate(onClosed);\n if (!onDestroyed) immediate.unref();\n stream.once(\"error\", onDone);\n stream.once(\"close\", onDone);\n cleanup();\n if (!stream.closed) {\n stream.destroy();\n }\n};\n//# sourceMappingURL=stream.js.map",
|
|
44
|
+
"/**\n * Adapters between Node streams and Effect streams, channels, and readables.\n *\n * This module is the stream boundary for Node APIs. It wraps `Readable` and\n * `Duplex` values as Effect `Stream`s and `Channel`s, pipes Effect streams\n * through Node duplex streams, exposes an Effect `Stream` back to Node as a\n * `Readable`, and collects readable payloads into strings, array buffers, or\n * `Uint8Array`s with optional byte limits.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Arr from \"effect/Array\";\nimport * as ByteSize from \"effect/ByteSize\";\nimport * as Cause from \"effect/Cause\";\nimport * as Channel from \"effect/Channel\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\nimport * as Fiber from \"effect/Fiber\";\nimport { dual } from \"effect/Function\";\nimport * as Latch from \"effect/Latch\";\nimport * as MutableRef from \"effect/MutableRef\";\nimport * as Pull from \"effect/Pull\";\nimport * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\nimport { finished, Readable } from \"node:stream\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport { destroyStream as destroyReadable } from \"./internal/stream.js\";\nimport { pullIntoWritable } from \"./NodeSink.js\";\n/**\n * Error indicating that a buffered Node stream exceeded its byte limit.\n *\n * @stability unstable\n * @category errors\n * @since 4.0.0\n */\nexport class MaxBytesError extends Error {\n _tag = \"MaxBytesError\";\n maxBytes;\n constructor(maxBytes) {\n super(\"maxBytes exceeded\");\n this.maxBytes = maxBytes;\n }\n}\n/**\n * Converts a Node readable stream into an Effect `Stream`, reading chunks with\n * independent read sizes and batch limits, mapping stream errors with `onError`,\n * and destroying the readable on completion unless `closeOnDone` is `false`.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromReadable = options => Stream.fromChannel(fromReadableChannel(options));\n/**\n * Creates a `Channel` that pulls chunks from a Node readable stream, mapping\n * errors with `onError` and destroying the readable on completion unless\n * `closeOnDone` is `false`.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromReadableChannel = options => Channel.fromTransform((_, scope) => readableToPullUnsafe({\n scope,\n readable: options.evaluate(),\n onError: options.onError ?? defaultOnError,\n chunkSize: options.chunkSize,\n readSize: options.readSize,\n closeOnDone: options.closeOnDone\n}));\n/**\n * Creates a `Channel` over a Node `Duplex`, writing upstream chunks with\n * backpressure while emitting chunks read from the duplex and optionally ending\n * the writable side when upstream completes.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const fromDuplex = options => Channel.fromTransform((upstream, scope) => {\n const duplex = options.evaluate();\n const exit = MutableRef.make(undefined);\n const latch = Latch.makeUnsafe(false);\n return pullIntoWritable({\n pull: upstream,\n writable: duplex,\n onError: options.onError ?? defaultOnError,\n endOnDone: options.endOnDone,\n encoding: options.encoding\n }).pipe(Effect.catchCause(cause => {\n if (Pull.isDoneCause(cause)) return Effect.void;\n exit.current = Exit.failCause(cause);\n latch.openUnsafe();\n return Effect.void;\n }), Effect.forkIn(scope), Effect.flatMap(() => readableToPullUnsafe({\n scope,\n exit,\n latch,\n readable: duplex,\n onError: options.onError ?? defaultOnError,\n chunkSize: options.chunkSize,\n readSize: options.readSize\n })));\n});\n/**\n * Pipes an Effect `Stream` through a Node `Duplex`, writing the stream's\n * chunks to the duplex and emitting chunks read back from it.\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const pipeThroughDuplex = /*#__PURE__*/dual(2, (self, options) => Stream.pipeThroughChannelOrFail(self, fromDuplex(options)));\n/**\n * Pipes a stream of strings or bytes through a Node `Duplex` using default\n * options and `Cause.UnknownError` for stream failures.\n *\n * @stability unstable\n * @category combinators\n * @since 4.0.0\n */\nexport const pipeThroughSimple = /*#__PURE__*/dual(2, (self, duplex) => pipeThroughDuplex(self, {\n evaluate: duplex\n}));\n/**\n * Converts an Effect `Stream` into a Node `Readable`, using the caller's\n * Effect context to run the stream and destroying the readable if the stream\n * fails.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toReadable = stream => Effect.map(Effect.context(), context => new StreamAdapter(context, stream));\n/**\n * Converts a service-free Effect `Stream` into a Node `Readable` using an\n * empty Effect context.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toReadableNever = stream => new StreamAdapter(Context.empty(), stream);\n/**\n * Consumes a Node readable stream into a string using the selected encoding,\n * failing through `onError` on stream errors or when `maxBytes` is exceeded\n * and destroying the stream on interruption or failure.\n * `maxBytes` counts the bytes read from the stream. Streams that already emit\n * strings are counted by encoded string length, which can differ from the\n * bytes originally read.\n * Set `destroyOnOverflow` to `false` to drain the remaining data instead of\n * destroying the stream when the byte limit is exceeded.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toString = (readable, options) => {\n const maxBytesNumber = toMaxBytes(options?.maxBytes);\n const onError = options?.onError ?? defaultOnError;\n const encoding = options?.encoding ?? \"utf8\";\n return Effect.callback(resume => {\n const stream = readable();\n // Decoding here keeps `maxBytes` on raw bytes. A stream that already\n // decodes only emits strings, so switch it to `encoding` instead.\n // Object-mode strings are not encoded bytes and count as UTF-8.\n const decodes = stream.readableEncoding !== null;\n if (decodes) stream.setEncoding(encoding);\n const decoder = new StringDecoder(encoding);\n let string = \"\";\n let bytes = 0;\n const cleanup = finished(stream, {\n readable: true,\n writable: false\n }, err => {\n stream.off(\"data\", onData);\n if (err) {\n destroyReadable(stream, cleanup);\n resume(Effect.fail(onError(err)));\n } else {\n cleanup();\n resume(Effect.succeed(string + decoder.end()));\n }\n });\n function onData(chunk) {\n if (typeof chunk === \"string\") {\n string += chunk;\n bytes += Buffer.byteLength(chunk, decodes ? encoding : \"utf8\");\n } else {\n string += decoder.write(chunk);\n bytes += chunk.byteLength;\n }\n if (maxBytesNumber !== undefined && bytes > maxBytesNumber) {\n stream.off(\"data\", onData);\n if (options?.destroyOnOverflow === false) {\n drainReadable(stream, cleanup);\n } else {\n destroyReadable(stream, cleanup);\n }\n resume(Effect.fail(onError(new MaxBytesError(maxBytesNumber))));\n }\n }\n stream.on(\"data\", onData);\n return Effect.sync(() => {\n stream.off(\"data\", onData);\n destroyReadable(stream, cleanup);\n });\n });\n};\n/**\n * Consumes a Node readable stream into an `ArrayBuffer`, failing through\n * `onError` on stream errors or when `maxBytes` is exceeded and destroying the\n * stream on interruption or failure.\n * Set `destroyOnOverflow` to `false` to drain the remaining data instead of\n * destroying the stream when the byte limit is exceeded.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toArrayBuffer = (readable, options) => {\n const maxBytesNumber = toMaxBytes(options?.maxBytes);\n const onError = options?.onError ?? defaultOnError;\n return Effect.callback(resume => {\n const stream = readable();\n const buffers = [];\n let bytes = 0;\n const cleanup = finished(stream, {\n readable: true,\n writable: false\n }, err => {\n stream.off(\"data\", onData);\n if (err) {\n destroyReadable(stream, cleanup);\n return resume(Effect.fail(onError(err)));\n }\n cleanup();\n const buffer = buffers.length === 1 ? buffers[0] : Buffer.concat(buffers);\n if (buffer.byteOffset === 0 && buffer.buffer.byteLength === buffer.byteLength) {\n return resume(Effect.succeed(buffer.buffer));\n }\n resume(Effect.succeed(buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength)));\n });\n function onData(chunk) {\n buffers.push(chunk);\n bytes += chunk.length;\n if (maxBytesNumber !== undefined && bytes > maxBytesNumber) {\n stream.off(\"data\", onData);\n if (options?.destroyOnOverflow === false) {\n drainReadable(stream, cleanup);\n } else {\n destroyReadable(stream, cleanup);\n }\n resume(Effect.fail(onError(new MaxBytesError(maxBytesNumber))));\n }\n }\n stream.on(\"data\", onData);\n return Effect.sync(() => {\n stream.off(\"data\", onData);\n destroyReadable(stream, cleanup);\n });\n });\n};\n/**\n * Consumes a Node readable stream into a `Uint8Array`, using the same error\n * mapping and `maxBytes` handling as `toArrayBuffer`.\n *\n * @stability unstable\n * @category converting\n * @since 4.0.0\n */\nexport const toUint8Array = (readable, options) => Effect.map(toArrayBuffer(readable, options), buffer => new Uint8Array(buffer));\n// ----------------------------------------------------------------------------\n// internal\n// ----------------------------------------------------------------------------\n// Keep consuming after the consumer's listeners are removed, so the producer\n// can finish and any late error stays handled.\nconst drainReadable = (stream, cleanup) => {\n cleanup();\n const done = finished(stream, {\n readable: true,\n writable: false\n }, () => done());\n stream.resume();\n};\nconst readableToPullUnsafe = options => {\n const readable = options.readable;\n const chunkSize = options.chunkSize ?? 4096;\n const closeOnDone = options.closeOnDone ?? true;\n const exit = options.exit ?? MutableRef.make(undefined);\n const latch = options.latch ?? Latch.makeUnsafe(false);\n function onReadable() {\n latch.openUnsafe();\n }\n readable.on(\"readable\", onReadable);\n const cleanup = finished(readable, {\n readable: true,\n writable: false\n }, error => {\n exit.current ??= Exit.fail(error ? options.onError(error) : Cause.Done());\n latch.openUnsafe();\n });\n const pull = Effect.suspend(function loop() {\n let item = options.readable.read(options.readSize);\n if (item === null) {\n if (exit.current) {\n return exit.current;\n }\n if (readable.readableEnded) {\n return Effect.fail(Cause.Done());\n }\n latch.closeUnsafe();\n return Effect.flatMap(latch.await, loop);\n }\n const chunk = Arr.of(item);\n // read() can synchronously refill the buffer, so null is not a batch bound.\n while (chunk.length < chunkSize) {\n item = options.readable.read(options.readSize);\n if (item === null) break;\n chunk.push(item);\n }\n return Effect.succeed(chunk);\n });\n return Effect.as(Scope.addFinalizer(options.scope, Effect.sync(() => {\n readable.off(\"readable\", onReadable);\n if (closeOnDone) {\n destroyReadable(readable, cleanup);\n } else {\n cleanup();\n }\n })), pull);\n};\nclass StreamAdapter extends Readable {\n readLatch;\n fiber = undefined;\n constructor(context, stream) {\n super({});\n this.readLatch = Latch.makeUnsafe(false);\n this.fiber = Stream.runForEachArray(stream, chunk => this.readLatch.whenOpen(Effect.sync(() => {\n this.readLatch.closeUnsafe();\n for (let i = 0; i < chunk.length; i++) {\n const item = chunk[i];\n if (typeof item === \"string\") {\n this.push(item, \"utf8\");\n } else {\n this.push(item);\n }\n }\n }))).pipe(this.readLatch.whenOpen, Effect.provideContext(context), Effect.runFork);\n this.fiber.addObserver(exit => {\n this.fiber = undefined;\n if (Exit.isSuccess(exit)) {\n this.push(null);\n } else {\n this.destroy(Cause.squash(exit.cause));\n }\n });\n }\n _read(_size) {\n this.readLatch.openUnsafe();\n }\n _destroy(error, callback) {\n if (!this.fiber) {\n return callback(error);\n }\n Effect.runFork(Fiber.interrupt(this.fiber)).addObserver(exit => {\n callback(exit._tag === \"Failure\" ? Cause.squash(exit.cause) : error);\n });\n }\n}\nconst defaultOnError = error => new Cause.UnknownError(error);\nconst toMaxBytes = maxBytes => maxBytes === undefined || maxBytes === Infinity ? undefined : Number(ByteSize.fromInputUnsafe(maxBytes));\n//# sourceMappingURL=NodeStream.js.map",
|
|
45
|
+
"/**\n * Shared Node-compatible implementation of Effect's `FileSystem` service.\n *\n * This module adapts Node's `node:fs`, `node:os`, and `node:path` APIs into a\n * `FileSystem` layer for Effect programs running on Node-compatible runtimes.\n * Platform packages use it to provide file and directory I/O, permissions,\n * links, metadata, temporary files and directories, and file watching through\n * the shared `FileSystem` service.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as BI from \"effect/BigInt\";\nimport * as ByteSize from \"effect/ByteSize\";\nimport * as Cause from \"effect/Cause\";\nimport * as Effect from \"effect/Effect\";\nimport { effectify } from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport { pipe } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Error from \"effect/PlatformError\";\nimport * as Queue from \"effect/Queue\";\nimport * as Stream from \"effect/Stream\";\nimport * as Crypto from \"node:crypto\";\nimport * as NFS from \"node:fs\";\nimport * as OS from \"node:os\";\nimport * as Path from \"node:path\";\nimport { handleErrnoException } from \"./internal/utils.js\";\nconst handleBadArgument = method => err => Error.badArgument({\n module: \"FileSystem\",\n method,\n description: err.message ?? String(err)\n});\nconst bigintToNumber = (value, field) => {\n const number = Number(value);\n if (!Number.isSafeInteger(number)) {\n throw new RangeError(`${field} exceeds the safe integer range: ${value}`);\n }\n return number;\n};\nconst bigintToNumberOption = value => Option.flatMap(Option.fromNullishOr(value), BI.toNumber);\n// Node fills bigint stats from a BigInt64Array, so unsigned 64-bit values such\n// as dev_t and ino_t at or above 2^63 are reported as negative.\nconst toUint64 = value => BigInt.asUintN(64, value);\nconst toUint64Option = value => Option.map(Option.fromNullishOr(value), toUint64);\n// fs.write ignores bigint positions.\nconst positionToNumber = (position, method) => Effect.try({\n try: () => bigintToNumber(position, \"position\"),\n catch: handleBadArgument(method)\n});\n// == access\nconst access = /*#__PURE__*/(() => {\n const nodeAccess = /*#__PURE__*/effectify(NFS.access, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"access\"), /*#__PURE__*/handleBadArgument(\"access\"));\n return (path, options) => {\n let mode = NFS.constants.F_OK;\n if (options?.readable) {\n mode |= NFS.constants.R_OK;\n }\n if (options?.writable) {\n mode |= NFS.constants.W_OK;\n }\n return nodeAccess(path, mode);\n };\n})();\n// == copy\nconst copy = /*#__PURE__*/(() => {\n const nodeCp = /*#__PURE__*/effectify(NFS.cp, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"copy\"), /*#__PURE__*/handleBadArgument(\"copy\"));\n return (fromPath, toPath, options) => nodeCp(fromPath, toPath, {\n force: options?.overwrite ?? false,\n preserveTimestamps: options?.preserveTimestamps ?? false,\n recursive: true\n });\n})();\n// == copyFile\nconst copyFile = /*#__PURE__*/(() => {\n const nodeCopyFile = /*#__PURE__*/effectify(NFS.copyFile, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"copyFile\"), /*#__PURE__*/handleBadArgument(\"copyFile\"));\n return (fromPath, toPath) => nodeCopyFile(fromPath, toPath);\n})();\n// == chmod\nconst chmod = /*#__PURE__*/(() => {\n const nodeChmod = /*#__PURE__*/effectify(NFS.chmod, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"chmod\"), /*#__PURE__*/handleBadArgument(\"chmod\"));\n return (path, mode) => nodeChmod(path, mode);\n})();\n// == chown\nconst chown = /*#__PURE__*/(() => {\n const nodeChown = /*#__PURE__*/effectify(NFS.chown, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"chown\"), /*#__PURE__*/handleBadArgument(\"chown\"));\n return (path, uid, gid) => nodeChown(path, uid, gid);\n})();\n// == link\nconst link = /*#__PURE__*/(() => {\n const nodeLink = /*#__PURE__*/effectify(NFS.link, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"link\"), /*#__PURE__*/handleBadArgument(\"link\"));\n return (existingPath, newPath) => nodeLink(existingPath, newPath);\n})();\n// == makeDirectory\nconst makeDirectory = /*#__PURE__*/(() => {\n const nodeMkdir = /*#__PURE__*/effectify(NFS.mkdir, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"makeDirectory\"), /*#__PURE__*/handleBadArgument(\"makeDirectory\"));\n return (path, options) => nodeMkdir(path, {\n recursive: options?.recursive ?? false,\n mode: options?.mode\n });\n})();\n// == makeTempDirectory\nconst makeTempDirectoryFactory = method => {\n const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n return options => Effect.suspend(() => {\n const prefix = options?.prefix ?? \"\";\n const directory = typeof options?.directory === \"string\" ? Path.join(options.directory, \".\") : OS.tmpdir();\n return nodeMkdtemp(prefix ? Path.join(directory, prefix) : directory + \"/\");\n });\n};\nconst makeTempDirectory = /*#__PURE__*/makeTempDirectoryFactory(\"makeTempDirectory\");\n// == remove\nconst removeFactory = method => {\n const nodeRm = effectify(NFS.rm, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n return (path, options) => nodeRm(path, {\n recursive: options?.recursive ?? false,\n force: options?.force ?? false\n });\n};\nconst remove = /*#__PURE__*/removeFactory(\"remove\");\n// == makeTempDirectoryScoped\nconst makeTempDirectoryScoped = /*#__PURE__*/(() => {\n const makeDirectory = /*#__PURE__*/makeTempDirectoryFactory(\"makeTempDirectoryScoped\");\n const removeDirectory = /*#__PURE__*/removeFactory(\"makeTempDirectoryScoped\");\n return options => Effect.acquireRelease(makeDirectory(options), directory => Effect.orDie(removeDirectory(directory, {\n recursive: true,\n force: true\n })));\n})();\n// == open\nconst openFlagBits = flag => {\n const {\n O_APPEND,\n O_CREAT,\n O_EXCL,\n O_RDONLY,\n O_RDWR,\n O_TRUNC,\n O_WRONLY\n } = NFS.constants;\n switch (flag) {\n case \"r\":\n return O_RDONLY;\n case \"r+\":\n return O_RDWR;\n case \"w\":\n return O_TRUNC | O_CREAT | O_WRONLY;\n case \"wx\":\n return O_TRUNC | O_CREAT | O_WRONLY | O_EXCL;\n case \"w+\":\n return O_TRUNC | O_CREAT | O_RDWR;\n case \"wx+\":\n return O_TRUNC | O_CREAT | O_RDWR | O_EXCL;\n case \"a\":\n return O_APPEND | O_CREAT | O_WRONLY;\n case \"ax\":\n return O_APPEND | O_CREAT | O_WRONLY | O_EXCL;\n case \"a+\":\n return O_APPEND | O_CREAT | O_RDWR;\n case \"ax+\":\n return O_APPEND | O_CREAT | O_RDWR | O_EXCL;\n }\n};\n// Reject unsupported platforms: libuv silently ignores unknown flags on Windows.\nconst noFollowFlags = (method, flag) => Effect.suspend(() => {\n const {\n O_NOFOLLOW\n } = NFS.constants;\n if (process.platform === \"win32\" || typeof O_NOFOLLOW !== \"number\" || O_NOFOLLOW === 0) {\n return Effect.fail(Error.badArgument({\n module: \"FileSystem\",\n method,\n description: \"noFollow is not supported on this platform\"\n }));\n }\n return Effect.succeed(openFlagBits(flag) | O_NOFOLLOW);\n});\nconst openFactory = method => {\n const nodeOpen = effectify(NFS.open, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n const nodeClose = effectify(NFS.close, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n return (path, options) => pipe(Effect.acquireRelease(options?.noFollow === true ? Effect.flatMap(noFollowFlags(method, options.flag ?? \"r\"), flags => nodeOpen(path, flags, options.mode)) : nodeOpen(path, options?.flag ?? \"r\", options?.mode), fd => Effect.orDie(nodeClose(fd))), Effect.map(fd => makeFile(fd, options?.flag?.startsWith(\"a\") ?? false)));\n};\nconst open = /*#__PURE__*/openFactory(\"open\");\nconst negativePosition = method => Error.badArgument({\n module: \"FileSystem\",\n method,\n description: \"Cannot read before the start of the file\"\n});\nconst makeFile = /*#__PURE__*/(() => {\n const nodeReadFactory = method => effectify(NFS.read, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n const nodeRead = /*#__PURE__*/nodeReadFactory(\"read\");\n const nodeReadAlloc = /*#__PURE__*/nodeReadFactory(\"readAlloc\");\n const nodeStat = /*#__PURE__*/effectify(NFS.fstat, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"stat\"), /*#__PURE__*/handleBadArgument(\"stat\"));\n const nodeTruncate = /*#__PURE__*/effectify(NFS.ftruncate, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"truncate\"), /*#__PURE__*/handleBadArgument(\"truncate\"));\n const nodeSync = /*#__PURE__*/effectify(NFS.fsync, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"sync\"), /*#__PURE__*/handleBadArgument(\"sync\"));\n const nodeWriteFactory = method => effectify(NFS.write, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n const nodeWrite = /*#__PURE__*/nodeWriteFactory(\"write\");\n const nodeWriteAll = /*#__PURE__*/nodeWriteFactory(\"writeAll\");\n class FileImpl {\n [FileSystem.FileTypeId];\n fd;\n append;\n position = /*#__PURE__*/BigInt(0);\n constructor(fd, append) {\n this[FileSystem.FileTypeId] = FileSystem.FileTypeId;\n this.fd = fd;\n this.append = append;\n }\n get stat() {\n return Effect.flatMap(nodeStat(this.fd, {\n bigint: true\n }), makeFileInfo);\n }\n get sync() {\n return nodeSync(this.fd);\n }\n seek(offset, from) {\n return Effect.suspend(() => {\n const position = from === \"start\" ? offset : this.position + offset;\n if (position < BigInt(0)) {\n return Effect.fail(Error.badArgument({\n module: \"FileSystem\",\n method: \"seek\",\n description: \"Cannot seek before the start of the file\"\n }));\n }\n this.position = position;\n return Effect.succeed(position);\n });\n }\n read(buffer, options) {\n return Effect.suspend(() => {\n const explicit = options?.position;\n if (explicit !== undefined) {\n return explicit < BigInt(0) ? Effect.fail(negativePosition(\"read\")) : nodeRead(this.fd, {\n buffer,\n position: explicit\n });\n }\n const position = this.position;\n return Effect.map(nodeRead(this.fd, {\n buffer,\n position\n }), bytesRead => {\n this.position = position + BigInt(bytesRead);\n return bytesRead;\n });\n });\n }\n readAlloc(size, options) {\n return Effect.suspend(() => {\n try {\n if (!Number.isInteger(size) || size < 0) {\n throw new RangeError(\"size must be a non-negative integer\");\n }\n const explicit = options?.position;\n if (explicit !== undefined && explicit < BigInt(0)) {\n return Effect.fail(negativePosition(\"readAlloc\"));\n }\n const buffer = Buffer.allocUnsafeSlow(size);\n const position = explicit ?? this.position;\n return Effect.map(nodeReadAlloc(this.fd, {\n buffer,\n position\n }), bytesRead => {\n if (bytesRead === 0) {\n return Option.none();\n }\n if (explicit === undefined) {\n this.position = position + BigInt(bytesRead);\n }\n if (bytesRead === size) {\n return Option.some(buffer);\n }\n const dst = Buffer.allocUnsafeSlow(bytesRead);\n buffer.copy(dst, 0, 0, bytesRead);\n return Option.some(dst);\n });\n } catch (cause) {\n return Effect.fail(handleBadArgument(\"readAlloc\")(cause));\n }\n });\n }\n truncate(length) {\n return Effect.map(nodeTruncate(this.fd, length || undefined), () => {\n if (!this.append) {\n const len = BigInt(length ?? 0);\n if (this.position > len) {\n this.position = len;\n }\n }\n });\n }\n write(buffer) {\n return Effect.suspend(() => {\n const position = this.position;\n return Effect.flatMap(this.append ? Effect.succeed(undefined) : positionToNumber(position, \"write\"), nodePosition => Effect.map(nodeWrite(this.fd, buffer, undefined, undefined, nodePosition), bytesWritten => {\n if (!this.append) {\n this.position = position + BigInt(bytesWritten);\n }\n return bytesWritten;\n }));\n });\n }\n writeAllChunk(buffer) {\n return Effect.suspend(() => {\n const position = this.position;\n return Effect.flatMap(this.append ? Effect.succeed(undefined) : positionToNumber(position, \"writeAll\"), nodePosition => Effect.flatMap(nodeWriteAll(this.fd, buffer, undefined, undefined, nodePosition), bytesWritten => {\n if (bytesWritten === 0) {\n return Effect.fail(Error.systemError({\n module: \"FileSystem\",\n method: \"writeAll\",\n _tag: \"WriteZero\",\n pathOrDescriptor: this.fd,\n description: \"write returned 0 bytes written\"\n }));\n }\n if (!this.append) {\n this.position = position + BigInt(bytesWritten);\n }\n return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.void;\n }));\n });\n }\n writeAll(buffer) {\n return buffer.length === 0 ? Effect.void : this.writeAllChunk(buffer);\n }\n }\n return (fd, append) => new FileImpl(fd, append);\n})();\n// == makeTempFile\nconst makeTempFileFactory = method => {\n const makeDirectory = makeTempDirectoryFactory(method);\n return Effect.fnUntraced(function* (options) {\n const directory = yield* makeDirectory(options);\n const random = Crypto.randomBytes(6).toString(\"hex\");\n const name = Path.join(directory, options?.suffix ? `${random}${options.suffix}` : random);\n yield* writeFile(name, new Uint8Array(0));\n return name;\n });\n};\nconst makeTempFile = /*#__PURE__*/makeTempFileFactory(\"makeTempFile\");\n// == makeTempFileScoped\nconst makeTempFileScoped = /*#__PURE__*/(() => {\n const makeFile = /*#__PURE__*/makeTempFileFactory(\"makeTempFileScoped\");\n const removeDirectory = /*#__PURE__*/removeFactory(\"makeTempFileScoped\");\n return options => Effect.acquireRelease(makeFile(options), file => Effect.orDie(removeDirectory(Path.dirname(file), {\n recursive: true,\n force: true\n })));\n})();\n// == readDirectory\nconst readDirectory = (path, options) => Effect.tryPromise({\n try: () => NFS.promises.readdir(path, options),\n catch: err => handleErrnoException(\"FileSystem\", \"readDirectory\")(err, [path])\n});\nconst readDirectoryEntries = path => Effect.tryPromise({\n try: () => NFS.promises.readdir(path, {\n withFileTypes: true\n }),\n catch: err => handleErrnoException(\"FileSystem\", \"readDirectoryEntries\")(err, [path])\n}).pipe(Effect.map(entries => entries.map(entry => ({\n name: entry.name,\n type: fileType(entry)\n}))));\n// == readFile\nconst readFile = path => Effect.callback((resume, signal) => {\n try {\n NFS.readFile(path, {\n signal\n }, (err, data) => {\n if (err) {\n resume(Effect.fail(handleErrnoException(\"FileSystem\", \"readFile\")(err, [path])));\n } else {\n resume(Effect.succeed(data));\n }\n });\n } catch (err) {\n resume(Effect.fail(handleBadArgument(\"readFile\")(err)));\n }\n});\n// == readLink\nconst readLink = /*#__PURE__*/(() => {\n const nodeReadLink = /*#__PURE__*/effectify(NFS.readlink, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"readLink\"), /*#__PURE__*/handleBadArgument(\"readLink\"));\n return path => nodeReadLink(path);\n})();\n// == realPath\nconst realPath = /*#__PURE__*/(() => {\n const nodeRealPath = /*#__PURE__*/effectify(process.platform === \"win32\" ? NFS.realpath.native : NFS.realpath, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"realPath\"), /*#__PURE__*/handleBadArgument(\"realPath\"));\n return path => nodeRealPath(path);\n})();\n// == rename\nconst rename = /*#__PURE__*/(() => {\n const nodeRename = /*#__PURE__*/effectify(NFS.rename, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"rename\"), /*#__PURE__*/handleBadArgument(\"rename\"));\n return (oldPath, newPath) => nodeRename(oldPath, newPath);\n})();\n// == stat\nconst fileType = stat => stat.isFile() ? \"File\" : stat.isDirectory() ? \"Directory\" : stat.isSymbolicLink() ? \"SymbolicLink\" : stat.isBlockDevice() ? \"BlockDevice\" : stat.isCharacterDevice() ? \"CharacterDevice\" : stat.isFIFO() ? \"FIFO\" : stat.isSocket() ? \"Socket\" : \"Unknown\";\nconst makeFileInfo = (stat, method = \"stat\") => Effect.try({\n try: () => ({\n type: fileType(stat),\n mtime: Option.fromNullishOr(stat.mtime),\n atime: Option.fromNullishOr(stat.atime),\n birthtime: Option.fromNullishOr(stat.birthtime),\n dev: toUint64(stat.dev),\n rdev: toUint64Option(stat.rdev),\n ino: toUint64Option(stat.ino),\n mode: bigintToNumber(stat.mode, \"mode\"),\n nlink: toUint64Option(stat.nlink),\n uid: bigintToNumberOption(stat.uid),\n gid: bigintToNumberOption(stat.gid),\n size: ByteSize.bytes(stat.size),\n blksize: stat.blksize !== undefined ? Option.some(ByteSize.bytes(stat.blksize)) : Option.none(),\n blocks: Option.fromNullishOr(stat.blocks)\n }),\n catch: handleBadArgument(method)\n});\nconst statFactory = (method, nodeStatFn) => {\n const nodeStat = effectify(nodeStatFn, handleErrnoException(\"FileSystem\", method), handleBadArgument(method));\n return path => Effect.flatMap(nodeStat(path, {\n bigint: true\n }), stat => makeFileInfo(stat, method));\n};\nconst stat = /*#__PURE__*/statFactory(\"stat\", NFS.stat);\nconst lstat = /*#__PURE__*/statFactory(\"lstat\", NFS.lstat);\n// == symlink\nconst symlink = /*#__PURE__*/(() => {\n const nodeSymlink = /*#__PURE__*/effectify(NFS.symlink, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"symlink\"), /*#__PURE__*/handleBadArgument(\"symlink\"));\n return (target, path) => nodeSymlink(target, path);\n})();\n// == truncate\nconst truncate = /*#__PURE__*/(() => {\n const nodeTruncate = /*#__PURE__*/effectify(NFS.truncate, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"truncate\"), /*#__PURE__*/handleBadArgument(\"truncate\"));\n return (path, length) => nodeTruncate(path, length);\n})();\n// == utimes\nconst utimes = /*#__PURE__*/(() => {\n const nodeUtimes = /*#__PURE__*/effectify(NFS.utimes, /*#__PURE__*/handleErrnoException(\"FileSystem\", \"utime\"), /*#__PURE__*/handleBadArgument(\"utime\"));\n return (path, atime, mtime) => nodeUtimes(path, atime, mtime);\n})();\n// == watch\nconst watchNode = (path, info, options) => Stream.callback(queue => Effect.acquireRelease(Effect.sync(() => {\n const directory = info.type === \"Directory\" ? path : Path.dirname(path);\n const watcher = NFS.watch(path, {\n recursive: options?.recursive ?? false\n }, (event, path) => {\n if (!path) return;\n switch (event) {\n case \"rename\":\n {\n Effect.runFork(Effect.matchEffect(stat(Path.resolve(directory, path)), {\n onSuccess: _ => Queue.offer(queue, {\n _tag: \"Create\",\n path\n }),\n onFailure: _ => Queue.offer(queue, {\n _tag: \"Remove\",\n path\n })\n }));\n return;\n }\n case \"change\":\n {\n Queue.offerUnsafe(queue, {\n _tag: \"Update\",\n path\n });\n return;\n }\n }\n });\n watcher.on(\"error\", error => {\n Queue.failCauseUnsafe(queue, Cause.fail(Error.systemError({\n module: \"FileSystem\",\n _tag: \"Unknown\",\n method: \"watch\",\n pathOrDescriptor: path,\n cause: error\n })));\n });\n watcher.on(\"close\", () => {\n Queue.endUnsafe(queue);\n });\n return watcher;\n}), watcher => Effect.sync(() => watcher.close())).pipe(Effect.tap(() => Effect.sync(() => options?.onReady?.()))));\nconst watch = (backend, path, options) => Effect.all([stat(path), Effect.serviceOption(FileSystem.WatchBackend)]).pipe(Effect.map(([stat, callerBackend]) => Option.orElse(callerBackend, () => backend).pipe(Option.flatMap(_ => _.register(path, stat, options)), Option.getOrElse(() => watchNode(path, stat, options)))), Stream.unwrap);\n// == writeFile\nconst writeFile = (path, data, options) => Effect.callback((resume, signal) => {\n try {\n NFS.writeFile(path, data, {\n signal,\n flag: options?.flag,\n mode: options?.mode\n }, err => {\n if (err) {\n resume(Effect.fail(handleErrnoException(\"FileSystem\", \"writeFile\")(err, [path])));\n } else {\n resume(Effect.void);\n }\n });\n } catch (err) {\n resume(Effect.fail(handleBadArgument(\"writeFile\")(err)));\n }\n});\nconst makeFileSystem = /*#__PURE__*/Effect.map(/*#__PURE__*/Effect.serviceOption(FileSystem.WatchBackend), backend => FileSystem.make({\n access,\n chmod,\n chown,\n copy,\n copyFile,\n link,\n lstat,\n makeDirectory,\n makeTempDirectory,\n makeTempDirectoryScoped,\n makeTempFile,\n makeTempFileScoped,\n open,\n readDirectory,\n readDirectoryEntries,\n readFile,\n readLink,\n realPath,\n remove,\n rename,\n stat,\n symlink,\n truncate,\n utimes,\n watch(path, options) {\n return watch(backend, path, options);\n },\n writeFile\n}));\n/**\n * Provides the `FileSystem` service backed by Node filesystem APIs, including\n * file operations, directory operations, links, metadata, and file watching.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.effect(FileSystem.FileSystem)(makeFileSystem);\n//# sourceMappingURL=NodeFileSystem.js.map",
|
|
46
|
+
"/**\n * Node.js `FileSystem` layer for programs that perform real filesystem I/O.\n *\n * The exported layer satisfies the platform-independent `FileSystem` service\n * with Node-backed operations for files, directories, metadata, permissions,\n * links, temporary paths, and path watching. Effects still call the service from\n * `effect/FileSystem`; this module only chooses the Node implementation.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as NodeFileSystem from \"@effect/platform-node-shared/NodeFileSystem\";\n/**\n * Provides the `FileSystem` service backed by Node filesystem APIs.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = NodeFileSystem.layer;\n//# sourceMappingURL=NodeFileSystem.js.map",
|
|
47
|
+
"/**\n * Node-backed provider for Effect's `Path` service.\n *\n * This module turns Node's `node:path` and `node:url` APIs into `Path` layers.\n * `layer` uses the host platform path implementation, while `layerPosix` and\n * `layerWin32` provide fixed POSIX and Windows variants. All three layers also\n * include helpers for converting between file paths and file URLs.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { make, Path } from \"effect/Path\";\nimport { BadArgument } from \"effect/PlatformError\";\nimport * as NodePath from \"node:path\";\nimport * as NodeUrl from \"node:url\";\nconst fileUrlOps = windows => ({\n fromFileUrl: url => Effect.try({\n try: () => NodeUrl.fileURLToPath(url, {\n windows\n }),\n catch: cause => new BadArgument({\n module: \"Path\",\n method: \"fromFileUrl\",\n cause\n })\n }),\n toFileUrl: path => Effect.try({\n try: () => NodeUrl.pathToFileURL(path, {\n windows\n }),\n catch: cause => new BadArgument({\n module: \"Path\",\n method: \"toFileUrl\",\n cause\n })\n })\n});\n/**\n * Provides the `Path` service using Node's POSIX path implementation plus\n * file URL conversion helpers.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerPosix = /*#__PURE__*/Layer.succeed(Path)(/*#__PURE__*/make({\n ...NodePath.posix,\n ... /*#__PURE__*/fileUrlOps(false)\n}));\n/**\n * Provides the `Path` service using Node's Windows path implementation plus\n * file URL conversion helpers.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWin32 = /*#__PURE__*/Layer.succeed(Path)(/*#__PURE__*/make({\n ...NodePath.win32,\n ... /*#__PURE__*/fileUrlOps(true)\n}));\n/**\n * Provides the default `Path` service using the host platform's Node path\n * implementation plus file URL conversion helpers.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.succeed(Path)(/*#__PURE__*/make({\n ...NodePath,\n ... /*#__PURE__*/fileUrlOps(undefined)\n}));\n//# sourceMappingURL=NodePath.js.map",
|
|
48
|
+
"/**\n * Node.js layers for Effect's `Path` service.\n *\n * This module provides the default, POSIX, and Windows variants of the\n * platform-independent `Path` service by reusing the shared Node path\n * implementation. The provided path services include Node file URL conversion\n * behavior.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as NodePath from \"@effect/platform-node-shared/NodePath\";\n/**\n * Provides the default Node `Path` service using the platform's `node:path`\n * implementation.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = NodePath.layer;\n/**\n * Provides the `Path` service using Node's POSIX path implementation,\n * regardless of the host platform.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerPosix = NodePath.layerPosix;\n/**\n * Provides the `Path` service using Node's Windows path implementation,\n * regardless of the host platform.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layerWin32 = NodePath.layerWin32;\n//# sourceMappingURL=NodePath.js.map",
|
|
49
|
+
"/**\n * Shared Node.js implementation of the Effect `Stdio` service.\n *\n * `NodeStdio` provides {@link Stdio.Stdio} from the current Node process. The\n * exported {@link layer} reads command-line arguments from `process.argv`,\n * consumes input from `process.stdin`, and writes normal and error output to\n * `process.stdout` and `process.stderr`. Standard input remains open, and\n * standard output and error output are not ended unless requested.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { systemError } from \"effect/PlatformError\";\nimport * as Stdio from \"effect/Stdio\";\nimport { fromWritable } from \"./NodeSink.js\";\nimport { fromReadable } from \"./NodeStream.js\";\n/**\n * Provides `Stdio` from `process.argv`, `process.stdin`, `process.stdout`,\n * and `process.stderr`; stdin remains open and stdout/stderr are not ended by\n * default.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.succeed(Stdio.Stdio, /*#__PURE__*/Stdio.make({\n args: /*#__PURE__*/Effect.sync(() => process.argv.slice(2)),\n stdinIsTerminal: /*#__PURE__*/Effect.sync(() => process.stdin.isTTY === true),\n stdoutIsTerminal: /*#__PURE__*/Effect.sync(() => process.stdout.isTTY === true),\n stderrIsTerminal: /*#__PURE__*/Effect.sync(() => process.stderr.isTTY === true),\n stdout: options => fromWritable({\n evaluate: () => process.stdout,\n onError: cause => systemError({\n module: \"Stdio\",\n method: \"stdout\",\n _tag: \"Unknown\",\n cause\n }),\n endOnDone: options?.endOnDone ?? false\n }),\n stderr: options => fromWritable({\n evaluate: () => process.stderr,\n onError: cause => systemError({\n module: \"Stdio\",\n method: \"stderr\",\n _tag: \"Unknown\",\n cause\n }),\n endOnDone: options?.endOnDone ?? false\n }),\n stdin: /*#__PURE__*/fromReadable({\n evaluate: () => process.stdin,\n onError: cause => systemError({\n module: \"Stdio\",\n method: \"stdin\",\n _tag: \"Unknown\",\n cause\n }),\n closeOnDone: false\n })\n}));\n//# sourceMappingURL=NodeStdio.js.map",
|
|
50
|
+
"/**\n * Node.js `Stdio` layer for the current process.\n *\n * The exported layer reuses the shared Node stdio implementation. It satisfies\n * the platform-independent `Stdio` service by reading command-line arguments\n * from `process.argv`, consuming input from `process.stdin`, and writing output\n * streams to `process.stdout` and `process.stderr`.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as NodeStdio from \"@effect/platform-node-shared/NodeStdio\";\n/**\n * Provides the `Stdio` service backed by the current process arguments,\n * stdin, stdout, and stderr streams.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = NodeStdio.layer;\n//# sourceMappingURL=NodeStdio.js.map",
|
|
51
|
+
"import * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport { badArgument } from \"effect/PlatformError\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Queue from \"effect/Queue\";\nimport * as RcRef from \"effect/RcRef\";\nimport * as Terminal from \"effect/Terminal\";\nimport * as readline from \"node:readline\";\n/**\n * Creates a scoped process-backed `Terminal` using Node `readline`, enabling\n * TTY raw mode while key input is read. By default, Esc, Ctrl+C, and Ctrl+D\n * end key input. Supply `shouldQuit` to override these quit keys.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = /*#__PURE__*/Effect.fnUntraced(function* (shouldQuit = defaultShouldQuit) {\n const stdin = process.stdin;\n const stdout = process.stdout;\n const lines = yield* Queue.make();\n // stdin \"end\" fires once per process, so remember end-of-input for readers\n // created after the event (Bun never sets `readableEnded`).\n let inputEnded = stdin.readableEnded;\n let readlineActive = false;\n const onStdinEnd = () => {\n inputEnded = true;\n if (!readlineActive) {\n Queue.endUnsafe(lines);\n }\n };\n stdin.once(\"end\", onStdinEnd);\n yield* Effect.addFinalizer(() => Effect.sync(() => stdin.off(\"end\", onStdinEnd)));\n const rlRef = yield* RcRef.make({\n acquire: Effect.acquireRelease(Effect.sync(() => {\n const rl = readline.createInterface({\n input: stdin,\n escapeCodeTimeout: 50\n });\n const onLine = line => Queue.offerUnsafe(lines, line);\n const onClose = () => {\n readlineActive = false;\n Queue.endUnsafe(lines);\n };\n readlineActive = true;\n readline.emitKeypressEvents(stdin, rl);\n rl.on(\"line\", onLine);\n rl.once(\"close\", onClose);\n return {\n rl,\n onClose,\n onLine\n };\n }), ({\n rl,\n onClose,\n onLine\n }) => Effect.sync(() => {\n readlineActive = false;\n rl.off(\"line\", onLine);\n rl.off(\"close\", onClose);\n rl.close();\n if (inputEnded) {\n Queue.endUnsafe(lines);\n }\n })),\n idleTimeToLive: \"10 millis\"\n });\n // Only key input needs raw mode; `readLine` never requests it.\n const setRawMode = enabled => Effect.sync(() => {\n if (stdin.isTTY) stdin.setRawMode(enabled);\n });\n const rawModeRef = yield* RcRef.make({\n acquire: Effect.acquireRelease(setRawMode(true), () => setRawMode(false)),\n idleTimeToLive: \"10 millis\"\n });\n const columns = Effect.sync(() => stdout.columns ?? 0);\n const rows = Effect.sync(() => stdout.rows ?? 0);\n const size = Effect.gen(function* () {\n const queue = yield* Queue.sliding(1);\n const onResize = () => Queue.offerUnsafe(queue, {\n columns: stdout.columns ?? 0,\n rows: stdout.rows ?? 0\n });\n yield* Effect.addFinalizer(() => Effect.sync(() => {\n stdout.off(\"resize\", onResize);\n Queue.endUnsafe(queue);\n }));\n stdout.on(\"resize\", onResize);\n onResize();\n return queue;\n });\n const readInput = Effect.gen(function* () {\n const queue = yield* Queue.make();\n const handleKeypress = (s, k) => {\n const userInput = {\n input: Option.fromUndefinedOr(s),\n key: {\n name: k.name ?? \"\",\n ctrl: !!k.ctrl,\n meta: !!k.meta,\n shift: !!k.shift\n }\n };\n Queue.offerUnsafe(queue, userInput);\n if (shouldQuit(userInput)) {\n Queue.endUnsafe(queue);\n }\n };\n // Deno's `process.stdin` shim does not keep the event loop alive, so a\n // program blocked on input can exit before `end` is ever delivered. A\n // timer holds the loop open for as long as this reader is active.\n const keepAlive = setInterval(() => {}, 2147483647);\n // Without this, consumers (e.g. `Prompt.run`) hang forever on closed stdin.\n const handleEnd = () => {\n clearInterval(keepAlive);\n Queue.endUnsafe(queue);\n };\n yield* Effect.addFinalizer(() => Effect.sync(() => {\n clearInterval(keepAlive);\n stdin.off(\"keypress\", handleKeypress);\n stdin.off(\"end\", handleEnd);\n }));\n stdin.on(\"keypress\", handleKeypress);\n if (inputEnded) {\n handleEnd();\n } else {\n yield* RcRef.get(rlRef);\n yield* RcRef.get(rawModeRef);\n stdin.once(\"end\", handleEnd);\n }\n return queue;\n });\n const readLine = Effect.suspend(() => Queue.poll(lines).pipe(Effect.flatMap(Option.match({\n onNone: () => Effect.scoped(Effect.andThen(RcRef.get(rlRef), Queue.take(lines))),\n onSome: Effect.succeed\n })), Effect.mapError(() => new Terminal.QuitError({}))));\n const display = prompt => Effect.uninterruptible(Effect.callback(resume => {\n stdout.write(prompt, err => Predicate.isNullish(err) ? resume(Effect.void) : resume(Effect.fail(badArgument({\n module: \"Terminal\",\n method: \"display\",\n description: \"Failed to write prompt to stdout\",\n cause: err\n }))));\n }));\n return Terminal.make({\n columns,\n rows,\n size,\n readInput,\n readLine,\n display\n });\n});\n/**\n * Provides the default process-backed `Terminal` service, ending key input on\n * bare Esc, Ctrl+C, or Ctrl+D.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.effect(Terminal.Terminal, /*#__PURE__*/make(defaultShouldQuit));\nfunction defaultShouldQuit(input) {\n const key = input.key;\n return key.name === \"escape\" || key.ctrl && (key.name === \"c\" || key.name === \"d\");\n}\n//# sourceMappingURL=NodeTerminal.js.map",
|
|
52
|
+
"/**\n * Node.js implementation of the Effect `Terminal` service.\n *\n * This module reuses the shared Node terminal implementation. `make` creates a\n * scoped process-backed `Terminal` service, and `layer` provides the default\n * service with the standard quit behavior for key input.\n *\n * @stability unstable\n * @since 4.0.0\n */\nimport * as NodeTerminal from \"@effect/platform-node-shared/NodeTerminal\";\n/**\n * Creates a scoped `Terminal` service backed by process stdin/stdout.\n * By default, Esc, Ctrl+C, and Ctrl+D end key input. Supply `shouldQuit` to\n * override these quit keys.\n *\n * @stability unstable\n * @category constructors\n * @since 4.0.0\n */\nexport const make = NodeTerminal.make;\n/**\n * Provides the default process-backed `Terminal` service, ending key input on\n * bare Esc, Ctrl+C, or Ctrl+D.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = NodeTerminal.layer;\n//# sourceMappingURL=NodeTerminal.js.map",
|
|
53
|
+
"import * as Layer from \"effect/Layer\";\nimport * as NodeChildProcessSpawner from \"./NodeChildProcessSpawner.js\";\nimport * as NodeFileSystem from \"./NodeFileSystem.js\";\nimport * as NodePath from \"./NodePath.js\";\nimport * as NodeStdio from \"./NodeStdio.js\";\nimport * as NodeTerminal from \"./NodeTerminal.js\";\n/**\n * Provides the default Node implementations for child process spawning,\n * filesystem, path, stdio, and terminal services.\n *\n * @stability unstable\n * @category layers\n * @since 4.0.0\n */\nexport const layer = /*#__PURE__*/Layer.provideMerge(NodeChildProcessSpawner.layer, /*#__PURE__*/Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer, NodeTerminal.layer));\n//# sourceMappingURL=NodeServices.js.map",
|
|
54
|
+
"import { __exportAll } from \"./_virtual/_rolldown/runtime.js\";\nimport { materializePlugin } from \"./DualRegistry.js\";\nimport { fromPlugin, toLayer } from \"./DualRuntime.js\";\nimport { layer, oauth2TokenRefresherLayer } from \"./OAuthFlow.js\";\nimport { isPlugin, make } from \"./Plugin.js\";\nimport { filesUnavailable } from \"./remote-runtime.js\";\nimport { PluginExecutionError, decodeInput, encodeOutput, execute, responseLimit } from \"./PluginRuntime.js\";\nimport \"./Runner.js\";\nimport { Cause, ConfigProvider, Context, Effect, Fiber, Formatter, Inspectable, Layer, ManagedRuntime, Match, Predicate, Redacted, Schema, Scope, String, pipe } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { NodeCrypto, NodeServices } from \"@effect/platform-node\";\n// src/Runner.ts\nvar Runner_exports = /* @__PURE__ */ __exportAll({\n\tOptions: () => Options,\n\tRunner: () => Runner_exports,\n\tload: () => load\n});\nconst guestOAuth = pipe(oauth2TokenRefresherLayer, Layer.provideMerge(layer), Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown({}))));\nfunction initializationError(cause) {\n\tif (Schema.is(PluginExecutionError)(cause)) return cause;\n\treturn PluginExecutionError.make({\n\t\tcategory: \"runner\",\n\t\tcause: Redacted.make(cause),\n\t\tmessage: pipe(Match.value(cause), Match.when(Predicate.isString, String.trim), Match.orElse((value) => Formatter.format(Inspectable.toJson(value), {\n\t\t\tignoreToString: true,\n\t\t\tspace: 2\n\t\t}))) || \"No error details returned by the plugin.\"\n\t});\n}\nconst Options = Schema.Struct({\n\tentrypoint: Schema.NonEmptyString,\n\texportName: Schema.NonEmptyString,\n\tmode: Schema.Literals([\"inspect\", \"execute\"]),\n\tversion: Schema.NonEmptyString\n});\nconst runtime = ManagedRuntime.make(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer));\n/**\n* Load a plugin export into the calling process. `execute` takes and returns plain JSON; aborting\n* its signal interrupts the invocation and settles the promise once its finalizers have run.\n*/\nfunction load(input) {\n\treturn runtime.runPromise(Effect.gen(function* () {\n\t\tconst options = yield* Schema.decodeUnknownEffect(Options)(input);\n\t\tconst guestServices = yield* Effect.context();\n\t\tconst scope = yield* Scope.make(\"sequential\");\n\t\tconst loaded = yield* Effect.cached(Effect.forkIn(Effect.gen(function* () {\n\t\t\tconst plugin = (yield* Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown))(yield* Effect.tryPromise({\n\t\t\t\ttry: () => import(options.entrypoint),\n\t\t\t\tcatch: initializationError\n\t\t\t})))[options.exportName];\n\t\t\tif (!isPlugin(plugin)) return yield* PluginExecutionError.make({\n\t\t\t\tcategory: \"protocol\",\n\t\t\t\tmessage: \"The configured export is not an integration plugin\"\n\t\t\t});\n\t\t\tyield* Effect.try({\n\t\t\t\ttry: () => make(plugin.identifier),\n\t\t\t\tcatch: initializationError\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tplugin,\n\t\t\t\tservices: yield* Effect.cached(Effect.forkIn(pipe(Layer.buildWithScope(pipe(toLayer(fromPlugin(plugin, options.version)), Layer.provideMerge(Layer.mergeAll(filesUnavailable, FetchHttpClient.layer, guestOAuth))), scope), Effect.provideContext(Context.makeUnsafe(guestServices.mapUnsafe))), scope))\n\t\t\t};\n\t\t}), scope));\n\t\tconst run = Effect.fnUntraced(function* (request) {\n\t\t\treturn yield* pipe(Effect.gen(function* () {\n\t\t\t\tconst { plugin, services } = yield* Fiber.join(yield* loaded);\n\t\t\t\tif (request.identity.pluginKey !== plugin.identifier && !(options.mode === \"inspect\" && \"_tag\" in request && request._tag === \"extract\")) return yield* PluginExecutionError.make({\n\t\t\t\t\tcategory: \"protocol\",\n\t\t\t\t\tmessage: \"Plugin identity does not match the request\"\n\t\t\t\t});\n\t\t\t\tif (request.identity.pluginVersion !== options.version) return yield* PluginExecutionError.make({\n\t\t\t\t\tcategory: \"protocol\",\n\t\t\t\t\tmessage: \"Plugin release does not match the request\"\n\t\t\t\t});\n\t\t\t\tif (\"_tag\" in request && request._tag === \"extract\") return {\n\t\t\t\t\t_tag: \"success\",\n\t\t\t\t\tidentity: request.identity,\n\t\t\t\t\tvalue: yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Json))(yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown))(materializePlugin(plugin, { version: request.identity.pluginVersion })))\n\t\t\t\t};\n\t\t\t\treturn yield* pipe(execute(request), Effect.provideContext(yield* Fiber.join(yield* services)));\n\t\t\t}), Effect.catchCauseIf((cause) => !Cause.hasInterrupts(cause), (cause) => options.mode === \"inspect\" ? Effect.fail(initializationError(Cause.squash(cause))) : Effect.succeed({\n\t\t\t\t_tag: \"failure\",\n\t\t\t\tidentity: request.identity,\n\t\t\t\terror: {\n\t\t\t\t\tcategory: \"initialization\",\n\t\t\t\t\tcode: \"PluginInitializationFailed\",\n\t\t\t\t\tmessage: \"Cannot initialize the installed plugin\",\n\t\t\t\t\tretryable: false\n\t\t\t\t}\n\t\t\t})));\n\t\t});\n\t\treturn { execute: (message, signal) => runtime.runPromise(pipe(Effect.gen(function* () {\n\t\t\tconst request = yield* decodeInput(message);\n\t\t\treturn yield* encodeOutput(yield* Effect.scoped(run(request)), responseLimit(request));\n\t\t}), Effect.mapError(initializationError)), { signal }) };\n\t}));\n}\nexport { Options, Runner_exports as Runner, load };\n\n//# sourceMappingURL=Runner.js.map"
|
|
55
|
+
],
|
|
56
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,eAAe,KAAK,KAAK;AAC/B,IAAM,cAAc;AAEb,IAAM,aAAa,CAAC,iBAAiB,UAAU;AAAA,EACpD,IAAI,MAAM,WAAW,IAAI;AAAA,IACvB,MAAM,IAAI,MAAM,sDAAsD,MAAM,QAAQ;AAAA,EACtF;AAAA,EACA,MAAM,YAAY,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,eAAe,CAAC,GAAG,YAAY;AAAA,EACjF,IAAI,MAAM;AAAA,EACV,S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