envapt 7.0.1 → 7.0.2

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/node/_virtual/_rolldown/runtime.cjs +1 -1
  4. package/dist/node/config.cjs +1 -1
  5. package/dist/node/config.cjs.map +1 -1
  6. package/dist/node/config.mjs +1 -1
  7. package/dist/node/config.mjs.map +1 -1
  8. package/dist/node/converters/BuiltInConverters.cjs +1 -1
  9. package/dist/node/converters/BuiltInConverters.cjs.map +1 -1
  10. package/dist/node/converters/BuiltInConverters.mjs +1 -1
  11. package/dist/node/converters/BuiltInConverters.mjs.map +1 -1
  12. package/dist/node/converters/Converters.cjs +1 -1
  13. package/dist/node/converters/Converters.cjs.map +1 -1
  14. package/dist/node/converters/Converters.mjs +1 -1
  15. package/dist/node/converters/Converters.mjs.map +1 -1
  16. package/dist/node/converters/ListOfBuiltInConverters.cjs +1 -1
  17. package/dist/node/converters/ListOfBuiltInConverters.cjs.map +1 -1
  18. package/dist/node/converters/ListOfBuiltInConverters.mjs +1 -1
  19. package/dist/node/converters/ListOfBuiltInConverters.mjs.map +1 -1
  20. package/dist/node/converters/ValueConverter.cjs +1 -1
  21. package/dist/node/converters/ValueConverter.cjs.map +1 -1
  22. package/dist/node/converters/ValueConverter.mjs +1 -1
  23. package/dist/node/converters/ValueConverter.mjs.map +1 -1
  24. package/dist/node/core/AdvancedMethods.cjs +1 -1
  25. package/dist/node/core/AdvancedMethods.cjs.map +1 -1
  26. package/dist/node/core/AdvancedMethods.mjs +1 -1
  27. package/dist/node/core/AdvancedMethods.mjs.map +1 -1
  28. package/dist/node/core/EnvapterBase.cjs +1 -1
  29. package/dist/node/core/EnvapterBase.cjs.map +1 -1
  30. package/dist/node/core/EnvapterBase.mjs +1 -1
  31. package/dist/node/core/EnvapterBase.mjs.map +1 -1
  32. package/dist/node/core/EnvironmentMethods.cjs +1 -1
  33. package/dist/node/core/EnvironmentMethods.cjs.map +1 -1
  34. package/dist/node/core/EnvironmentMethods.mjs +1 -1
  35. package/dist/node/core/EnvironmentMethods.mjs.map +1 -1
  36. package/dist/node/core/PrimitiveMethods.cjs +1 -1
  37. package/dist/node/core/PrimitiveMethods.cjs.map +1 -1
  38. package/dist/node/core/PrimitiveMethods.mjs +1 -1
  39. package/dist/node/core/PrimitiveMethods.mjs.map +1 -1
  40. package/dist/node/decorators/legacy/Envapt.cjs +1 -1
  41. package/dist/node/decorators/legacy/Envapt.cjs.map +1 -1
  42. package/dist/node/decorators/legacy/Envapt.mjs +1 -1
  43. package/dist/node/decorators/legacy/Envapt.mjs.map +1 -1
  44. package/dist/node/decorators/legacy/SugarDecorators.cjs +1 -1
  45. package/dist/node/decorators/legacy/SugarDecorators.cjs.map +1 -1
  46. package/dist/node/decorators/legacy/SugarDecorators.mjs +1 -1
  47. package/dist/node/decorators/legacy/SugarDecorators.mjs.map +1 -1
  48. package/dist/node/decorators/legacy/createPropertyDecorator.cjs +1 -1
  49. package/dist/node/decorators/legacy/createPropertyDecorator.cjs.map +1 -1
  50. package/dist/node/decorators/legacy/createPropertyDecorator.mjs +1 -1
  51. package/dist/node/decorators/legacy/createPropertyDecorator.mjs.map +1 -1
  52. package/dist/node/decorators/modern/Envapt.cjs +1 -1
  53. package/dist/node/decorators/modern/Envapt.cjs.map +1 -1
  54. package/dist/node/decorators/modern/Envapt.mjs +1 -1
  55. package/dist/node/decorators/modern/Envapt.mjs.map +1 -1
  56. package/dist/node/decorators/modern/SugarDecorators.cjs +1 -1
  57. package/dist/node/decorators/modern/SugarDecorators.cjs.map +1 -1
  58. package/dist/node/decorators/modern/SugarDecorators.mjs +1 -1
  59. package/dist/node/decorators/modern/SugarDecorators.mjs.map +1 -1
  60. package/dist/node/decorators/modern/createAccessorDecorator.cjs +1 -1
  61. package/dist/node/decorators/modern/createAccessorDecorator.cjs.map +1 -1
  62. package/dist/node/decorators/modern/createAccessorDecorator.mjs +1 -1
  63. package/dist/node/decorators/modern/createAccessorDecorator.mjs.map +1 -1
  64. package/dist/node/decorators/parseEnvaptOptions.cjs +1 -1
  65. package/dist/node/decorators/parseEnvaptOptions.cjs.map +1 -1
  66. package/dist/node/decorators/parseEnvaptOptions.mjs +1 -1
  67. package/dist/node/decorators/parseEnvaptOptions.mjs.map +1 -1
  68. package/dist/node/decorators/resolveDecoratorValue.cjs +1 -1
  69. package/dist/node/decorators/resolveDecoratorValue.cjs.map +1 -1
  70. package/dist/node/decorators/resolveDecoratorValue.mjs +1 -1
  71. package/dist/node/decorators/resolveDecoratorValue.mjs.map +1 -1
  72. package/dist/node/engine/Envapter.cjs +1 -1
  73. package/dist/node/engine/Envapter.cjs.map +1 -1
  74. package/dist/node/engine/Envapter.mjs +1 -1
  75. package/dist/node/engine/Envapter.mjs.map +1 -1
  76. package/dist/node/engine/NodeEnvapter.cjs +1 -1
  77. package/dist/node/engine/NodeEnvapter.cjs.map +1 -1
  78. package/dist/node/engine/NodeEnvapter.mjs +1 -1
  79. package/dist/node/engine/NodeEnvapter.mjs.map +1 -1
  80. package/dist/node/engine/TemplateResolver.cjs +1 -1
  81. package/dist/node/engine/TemplateResolver.cjs.map +1 -1
  82. package/dist/node/engine/TemplateResolver.mjs +1 -1
  83. package/dist/node/engine/TemplateResolver.mjs.map +1 -1
  84. package/dist/node/engine/Validators.cjs +1 -1
  85. package/dist/node/engine/Validators.cjs.map +1 -1
  86. package/dist/node/engine/Validators.mjs +1 -1
  87. package/dist/node/engine/Validators.mjs.map +1 -1
  88. package/dist/node/index.cjs +1 -1
  89. package/dist/node/index.mjs +1 -1
  90. package/dist/node/infra/Debug.cjs +1 -1
  91. package/dist/node/infra/Debug.cjs.map +1 -1
  92. package/dist/node/infra/Debug.mjs +1 -1
  93. package/dist/node/infra/Debug.mjs.map +1 -1
  94. package/dist/node/infra/Dotenv.cjs +1 -1
  95. package/dist/node/infra/Dotenv.cjs.map +1 -1
  96. package/dist/node/infra/Dotenv.mjs +1 -1
  97. package/dist/node/infra/Dotenv.mjs.map +1 -1
  98. package/dist/node/infra/Error.cjs +1 -1
  99. package/dist/node/infra/Error.cjs.map +1 -1
  100. package/dist/node/infra/Error.mjs +1 -1
  101. package/dist/node/infra/Error.mjs.map +1 -1
  102. package/dist/node/infra/runtime.cjs +1 -1
  103. package/dist/node/infra/runtime.cjs.map +1 -1
  104. package/dist/node/infra/runtime.mjs +1 -1
  105. package/dist/node/infra/runtime.mjs.map +1 -1
  106. package/dist/node/legacy.cjs +1 -1
  107. package/dist/node/legacy.mjs +1 -1
  108. package/dist/node/sources/ManualEnvSource.cjs +1 -1
  109. package/dist/node/sources/ManualEnvSource.cjs.map +1 -1
  110. package/dist/node/sources/ManualEnvSource.mjs +1 -1
  111. package/dist/node/sources/ManualEnvSource.mjs.map +1 -1
  112. package/dist/node/sources/NodeEnvSource.cjs +1 -1
  113. package/dist/node/sources/NodeEnvSource.cjs.map +1 -1
  114. package/dist/node/sources/NodeEnvSource.mjs +1 -1
  115. package/dist/node/sources/NodeEnvSource.mjs.map +1 -1
  116. package/dist/node/sources/UnboundEnvSource.cjs +1 -1
  117. package/dist/node/sources/UnboundEnvSource.cjs.map +1 -1
  118. package/dist/node/sources/UnboundEnvSource.mjs +1 -1
  119. package/dist/node/sources/UnboundEnvSource.mjs.map +1 -1
  120. package/dist/node/sources/WorkerEnvSource.cjs +1 -1
  121. package/dist/node/sources/WorkerEnvSource.cjs.map +1 -1
  122. package/dist/node/sources/WorkerEnvSource.mjs +1 -1
  123. package/dist/node/sources/WorkerEnvSource.mjs.map +1 -1
  124. package/dist/node/sources/coerce.cjs +1 -1
  125. package/dist/node/sources/coerce.cjs.map +1 -1
  126. package/dist/node/sources/coerce.mjs +1 -1
  127. package/dist/node/sources/coerce.mjs.map +1 -1
  128. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"Dotenv.mjs","names":[],"sources":["../../../src/infra/Dotenv.ts"],"sourcesContent":["import { debugVerbose, debugWarn } from './Debug';\n\n/**\n * Public options for the internal `.env` loader. Mirrors the subset of dotenv's\n * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).\n * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).\n *\n * @public\n */\nexport interface EnvFileOptions {\n /** Encoding for reading .env files. Defaults to 'utf8'. */\n encoding?: string;\n /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */\n override?: boolean;\n}\n\n/**\n * Internal call signature used by `EnvapterBase`. The `path` and `processEnv`\n * fields are managed by envapt and never user-supplied.\n * @internal\n */\nexport interface LoadDotenvInput extends EnvFileOptions {\n path: string | string[];\n processEnv: Record<string, string>;\n // Injected so the loader stays free of `node:fs`. Returns `undefined` when the file is absent.\n readFile(path: string, encoding: string): string | undefined;\n}\n\n// Matches: optional `export`, KEY name, optional whitespace, `=`, optional whitespace, value tail.\n// Multi-line quoted values are handled by re-buffering subsequent lines below.\n// Bounded by anchors with linear-time quantifiers; no catastrophic backtracking risk -- justified\n// eslint-disable-next-line security/detect-unsafe-regex\nconst KEY_LINE_RE = /^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=(.*)$/u;\n\n/**\n * Parse a `.env` text blob into a `Map<string, string>`.\n *\n * Supported syntax:\n * - `KEY=value` and `export KEY=value`\n * - blank lines and full-line `# comments`\n * - single-quoted `'literal'` values (no escape interpretation)\n * - double-quoted `\"value\"` values (interprets `\\n`, `\\r`, `\\t`, `\\\\`, `\\\"`)\n * - backtick-quoted values (literal, like single quotes)\n * - quoted values may span multiple lines\n * - inline `# comment` after an unquoted value (requires whitespace before `#`)\n * - empty values resolve to `\"\"`\n *\n * Mirrors dotenv's quirk where unescaped inner quotes inside a quoted value\n * are tolerated by greedy-matching to the rightmost matching quote on the\n * (possibly multi-line) value buffer. This is what lets a value like\n * `JSON=\"{\"name\":\"x\"}\"` round-trip without escaping.\n *\n * Does NOT perform `${VAR}` expansion — envapt's `Parser` handles that downstream.\n * @internal\n */\nexport function parseDotenv(src: string): Map<string, string> {\n const out = new Map<string, string>();\n const lines = src.split(/\\r?\\n/u);\n\n for (let i = 0; i < lines.length; i++) {\n const consumed = parseEntry(lines, i);\n i = consumed.endLine;\n if (consumed.entry) out.set(consumed.entry.key, consumed.entry.value);\n }\n\n return out;\n}\n\ninterface ParsedEntry {\n key: string;\n value: string;\n}\n\nfunction parseEntry(lines: string[], start: number): { entry: ParsedEntry | undefined; endLine: number } {\n /* v8 ignore next -- @preserve caller bounds-checks start so this never falls back */\n const line = lines[start] ?? '';\n const trimmedLine = line.trim();\n if (trimmedLine === '' || trimmedLine.startsWith('#')) return { entry: undefined, endLine: start };\n\n const match = line.match(KEY_LINE_RE);\n if (!match) return { entry: undefined, endLine: start };\n\n const key = match[1] as string;\n // Drop only leading whitespace before the value; trailing whitespace and inline comments\n // are dealt with below depending on whether the value is quoted.\n /* v8 ignore next -- @preserve regex group 2 always matches via `(.*)`, fallback is defensive */\n const rest = (match[2] ?? '').replace(/^\\s+/u, '');\n const firstChar = rest[0];\n\n if (firstChar === '\"' || firstChar === \"'\" || firstChar === '`') {\n const consumed = consumeQuotedValue(rest, lines, start, firstChar);\n return { entry: { key, value: consumed.value }, endLine: consumed.endLine };\n }\n\n return { entry: { key, value: stripInlineComment(rest) }, endLine: start };\n}\n\nfunction consumeQuotedValue(\n firstLineRest: string,\n lines: string[],\n startLine: number,\n quote: string\n): { value: string; endLine: number } {\n let buffer = firstLineRest;\n let cursor = startLine;\n let closeIdx = findLastUnescapedQuote(buffer, quote);\n\n while (closeIdx < 0 && cursor < lines.length - 1) {\n cursor++;\n /* v8 ignore next -- @preserve cursor is bounded by the while condition above */\n buffer += `\\n${lines[cursor] ?? ''}`;\n closeIdx = findLastUnescapedQuote(buffer, quote);\n }\n\n const inner = closeIdx > 0 ? buffer.slice(1, closeIdx) : buffer.slice(1);\n return { value: quote === '\"' ? unescapeDouble(inner) : inner, endLine: cursor };\n}\n\nfunction stripInlineComment(value: string): string {\n const hashIdx = findInlineCommentStart(value);\n const stripped = hashIdx === -1 ? value : value.slice(0, hashIdx);\n return stripped.trimEnd();\n}\n\nfunction findInlineCommentStart(value: string): number {\n for (let i = 0; i < value.length; i++) {\n if (value[i] === '#' && (i === 0 || /\\s/u.test(value[i - 1] as string))) return i;\n }\n return -1;\n}\n\n/**\n * Find the rightmost matching closing quote in `buffer` (skipping index 0 which is the\n * opening quote). For `\"`, a quote preceded by an odd number of backslashes is escaped\n * and ignored. Single and backtick quotes do not unescape.\n */\nfunction findLastUnescapedQuote(buffer: string, quote: string): number {\n for (let i = buffer.length - 1; i > 0; i--) {\n if (buffer[i] !== quote) continue;\n if (quote === '\"') {\n let backslashes = 0;\n let k = i - 1;\n while (k >= 0 && buffer[k] === '\\\\') {\n backslashes++;\n k--;\n }\n if (backslashes % 2 === 1) continue; // escaped\n }\n return i;\n }\n return -1;\n}\n\nfunction unescapeDouble(raw: string): string {\n let out = '';\n for (let i = 0; i < raw.length; i++) {\n const ch = raw[i];\n if (ch !== '\\\\' || i === raw.length - 1) {\n out += ch;\n continue;\n }\n const next = raw[i + 1];\n i++;\n switch (next) {\n case 'n':\n out += '\\n';\n break;\n case 'r':\n out += '\\r';\n break;\n case 't':\n out += '\\t';\n break;\n case '\\\\':\n out += '\\\\';\n break;\n case '\"':\n out += '\"';\n break;\n default:\n /* v8 ignore next -- @preserve `next` is always defined when this branch is reached (guarded above) */\n out += `\\\\${next ?? ''}`;\n }\n }\n return out;\n}\n\n/**\n * Load one or more `.env` files into a target `processEnv` map. Mirrors the\n * subset of dotenv's `config()` semantics that envapt depends on: first-wins\n * across multiple paths by default, optional `override: true`, optional\n * non-UTF8 encoding, missing files are skipped silently.\n *\n * Returns the set of keys actually written into `input.processEnv`. Skipped\n * collisions (under default `override: false`) are NOT included.\n * @internal\n */\nexport function loadDotenv(input: LoadDotenvInput): Set<string> {\n const paths = Array.isArray(input.path) ? input.path : [input.path];\n const encoding = input.encoding ?? 'utf8';\n const override = input.override ?? false;\n const written = new Set<string>();\n\n for (const filePath of paths) {\n const src = input.readFile(filePath, encoding);\n if (src === undefined) {\n debugWarn(`could not read ${filePath}`);\n continue;\n }\n\n const parsed = parseDotenv(src);\n debugVerbose(`loaded ${filePath}: ${parsed.size} ${parsed.size === 1 ? 'key' : 'keys'}`);\n for (const [key, value] of parsed) {\n const exists = Object.prototype.hasOwnProperty.call(input.processEnv, key);\n if (!exists || override) {\n input.processEnv[key] = value;\n written.add(key);\n debugVerbose(`${filePath} -> ${key}`);\n }\n }\n }\n\n return written;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"Dotenv.mjs","names":[],"sources":["../../../src/infra/Dotenv.ts"],"sourcesContent":["import { debugVerbose, debugWarn } from './Debug';\n\n/**\n * Public options for the internal `.env` loader. Mirrors the subset of dotenv's\n * `config()` options that envapt actually supports (no DOTENV_KEY, no quiet).\n * For debug output, use `Envapter.debug` (or the `ENVAPT_DEBUG` env var).\n *\n * @public\n */\nexport interface EnvFileOptions {\n /** Encoding for reading .env files. Defaults to 'utf8'. */\n encoding?: string;\n /** When true, later files override earlier ones (and existing processEnv values). Default false (first-wins). */\n override?: boolean;\n}\n\n/**\n * Internal call signature used by `EnvapterBase`. The `path` and `processEnv`\n * fields are managed by envapt and never user-supplied.\n * @internal\n */\nexport interface LoadDotenvInput extends EnvFileOptions {\n path: string | string[];\n processEnv: Record<string, string>;\n // Injected so the loader stays free of `node:fs`. Returns `undefined` when the file is absent.\n readFile(path: string, encoding: string): string | undefined;\n}\n\n// Matches: optional `export`, KEY name, optional whitespace, `=`, optional whitespace, value tail.\n// Multi-line quoted values are handled by re-buffering subsequent lines below.\n// Bounded by anchors with linear-time quantifiers; no catastrophic backtracking risk -- justified\n// eslint-disable-next-line security/detect-unsafe-regex\nconst KEY_LINE_RE = /^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=(.*)$/u;\n\n/**\n * Parse a `.env` text blob into a `Map<string, string>`.\n *\n * Supported syntax:\n * - `KEY=value` and `export KEY=value`\n * - blank lines and full-line `# comments`\n * - single-quoted `'literal'` values (no escape interpretation)\n * - double-quoted `\"value\"` values (interprets `\\n`, `\\r`, `\\t`, `\\\\`, `\\\"`)\n * - backtick-quoted values (literal, like single quotes)\n * - quoted values may span multiple lines\n * - inline `# comment` after an unquoted value (requires whitespace before `#`)\n * - empty values resolve to `\"\"`\n *\n * Mirrors dotenv's quirk where unescaped inner quotes inside a quoted value\n * are tolerated by greedy-matching to the rightmost matching quote on the\n * (possibly multi-line) value buffer. This is what lets a value like\n * `JSON=\"{\"name\":\"x\"}\"` round-trip without escaping.\n *\n * Does NOT perform `${VAR}` expansion — envapt's `Parser` handles that downstream.\n * @internal\n */\nexport function parseDotenv(src: string): Map<string, string> {\n const out = new Map<string, string>();\n const lines = src.split(/\\r?\\n/u);\n\n for (let i = 0; i < lines.length; i++) {\n const consumed = parseEntry(lines, i);\n i = consumed.endLine;\n if (consumed.entry) out.set(consumed.entry.key, consumed.entry.value);\n }\n\n return out;\n}\n\ninterface ParsedEntry {\n key: string;\n value: string;\n}\n\nfunction parseEntry(lines: string[], start: number): { entry: ParsedEntry | undefined; endLine: number } {\n /* v8 ignore next -- @preserve caller bounds-checks start so this never falls back */\n const line = lines[start] ?? '';\n const trimmedLine = line.trim();\n if (trimmedLine === '' || trimmedLine.startsWith('#')) return { entry: undefined, endLine: start };\n\n const match = line.match(KEY_LINE_RE);\n if (!match) return { entry: undefined, endLine: start };\n\n const key = match[1] as string;\n // Drop only leading whitespace before the value; trailing whitespace and inline comments\n // are dealt with below depending on whether the value is quoted.\n /* v8 ignore next -- @preserve regex group 2 always matches via `(.*)`, fallback is defensive */\n const rest = (match[2] ?? '').replace(/^\\s+/u, '');\n const firstChar = rest[0];\n\n if (firstChar === '\"' || firstChar === \"'\" || firstChar === '`') {\n const consumed = consumeQuotedValue(rest, lines, start, firstChar);\n return { entry: { key, value: consumed.value }, endLine: consumed.endLine };\n }\n\n return { entry: { key, value: stripInlineComment(rest) }, endLine: start };\n}\n\nfunction consumeQuotedValue(\n firstLineRest: string,\n lines: string[],\n startLine: number,\n quote: string\n): { value: string; endLine: number } {\n let buffer = firstLineRest;\n let cursor = startLine;\n let closeIdx = findLastUnescapedQuote(buffer, quote);\n\n while (closeIdx < 0 && cursor < lines.length - 1) {\n cursor++;\n /* v8 ignore next -- @preserve cursor is bounded by the while condition above */\n buffer += `\\n${lines[cursor] ?? ''}`;\n closeIdx = findLastUnescapedQuote(buffer, quote);\n }\n\n const inner = closeIdx > 0 ? buffer.slice(1, closeIdx) : buffer.slice(1);\n return { value: quote === '\"' ? unescapeDouble(inner) : inner, endLine: cursor };\n}\n\nfunction stripInlineComment(value: string): string {\n const hashIdx = findInlineCommentStart(value);\n const stripped = hashIdx === -1 ? value : value.slice(0, hashIdx);\n return stripped.trimEnd();\n}\n\nfunction findInlineCommentStart(value: string): number {\n for (let i = 0; i < value.length; i++) {\n if (value[i] === '#' && (i === 0 || /\\s/u.test(value[i - 1] as string))) return i;\n }\n return -1;\n}\n\n/**\n * Find the rightmost matching closing quote in `buffer` (skipping index 0 which is the\n * opening quote). For `\"`, a quote preceded by an odd number of backslashes is escaped\n * and ignored. Single and backtick quotes do not unescape.\n */\nfunction findLastUnescapedQuote(buffer: string, quote: string): number {\n for (let i = buffer.length - 1; i > 0; i--) {\n if (buffer[i] !== quote) continue;\n if (quote === '\"') {\n let backslashes = 0;\n let k = i - 1;\n while (k >= 0 && buffer[k] === '\\\\') {\n backslashes++;\n k--;\n }\n if (backslashes % 2 === 1) continue; // escaped\n }\n return i;\n }\n return -1;\n}\n\nfunction unescapeDouble(raw: string): string {\n let out = '';\n for (let i = 0; i < raw.length; i++) {\n const ch = raw[i];\n if (ch !== '\\\\' || i === raw.length - 1) {\n out += ch;\n continue;\n }\n const next = raw[i + 1];\n i++;\n switch (next) {\n case 'n':\n out += '\\n';\n break;\n case 'r':\n out += '\\r';\n break;\n case 't':\n out += '\\t';\n break;\n case '\\\\':\n out += '\\\\';\n break;\n case '\"':\n out += '\"';\n break;\n default:\n /* v8 ignore next -- @preserve `next` is always defined when this branch is reached (guarded above) */\n out += `\\\\${next ?? ''}`;\n }\n }\n return out;\n}\n\n/**\n * Load one or more `.env` files into a target `processEnv` map. Mirrors the\n * subset of dotenv's `config()` semantics that envapt depends on: first-wins\n * across multiple paths by default, optional `override: true`, optional\n * non-UTF8 encoding, missing files are skipped silently.\n *\n * Returns the set of keys actually written into `input.processEnv`. Skipped\n * collisions (under default `override: false`) are NOT included.\n * @internal\n */\nexport function loadDotenv(input: LoadDotenvInput): Set<string> {\n const paths = Array.isArray(input.path) ? input.path : [input.path];\n const encoding = input.encoding ?? 'utf8';\n const override = input.override ?? false;\n const written = new Set<string>();\n\n for (const filePath of paths) {\n const src = input.readFile(filePath, encoding);\n if (src === undefined) {\n debugWarn(`could not read ${filePath}`);\n continue;\n }\n\n const parsed = parseDotenv(src);\n debugVerbose(`loaded ${filePath}: ${parsed.size} ${parsed.size === 1 ? 'key' : 'keys'}`);\n for (const [key, value] of parsed) {\n const exists = Object.prototype.hasOwnProperty.call(input.processEnv, key);\n if (!exists || override) {\n input.processEnv[key] = value;\n written.add(key);\n debugVerbose(`${filePath} -> ${key}`);\n }\n }\n }\n\n return written;\n}\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};exports.EnvaptError=t,exports.EnvaptErrorCodes=e;
1
+ let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};exports.EnvaptError=t,exports.EnvaptErrorCodes=e;
2
2
  //# sourceMappingURL=Error.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.cjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"mDAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
1
+ {"version":3,"file":"Error.cjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};export{t as EnvaptError,e as EnvaptErrorCodes};
1
+ let e=function(e){return e[e.InvalidFallback=101]=`InvalidFallback`,e[e.InvalidFallbackType=102]=`InvalidFallbackType`,e[e.ArrayFallbackElementTypeMismatch=103]=`ArrayFallbackElementTypeMismatch`,e[e.FallbackConverterTypeMismatch=104]=`FallbackConverterTypeMismatch`,e[e.MalformedTimeFallback=105]=`MalformedTimeFallback`,e[e.InvalidArrayConverterType=201]=`InvalidArrayConverterType`,e[e.InvalidBuiltInConverter=202]=`InvalidBuiltInConverter`,e[e.InvalidCustomConverter=203]=`InvalidCustomConverter`,e[e.InvalidConverterType=204]=`InvalidConverterType`,e[e.PrimitiveCoercionFailed=205]=`PrimitiveCoercionFailed`,e[e.ArrayElementConversionFailed=206]=`ArrayElementConversionFailed`,e[e.EmptyArrayElement=207]=`EmptyArrayElement`,e[e.SchemaValidationFailed=208]=`SchemaValidationFailed`,e[e.SchemaThrew=209]=`SchemaThrew`,e[e.MissingDelimiter=301]=`MissingDelimiter`,e[e.InvalidUserDefinedConfig=302]=`InvalidUserDefinedConfig`,e[e.EnvFilesNotFound=303]=`EnvFilesNotFound`,e[e.InvalidKeyInput=304]=`InvalidKeyInput`,e[e.MissingEnvValue=305]=`MissingEnvValue`,e[e.FileApiUnsupported=306]=`FileApiUnsupported`,e[e.NoSourceBound=307]=`NoSourceBound`,e}({});var t=class extends Error{code;issues;constructor(e,t,n){super(t,n?.cause===void 0?void 0:{cause:n.cause}),this.name=`EnvaptError [${e}]`,this.code=e,this.issues=n?.issues}};export{t as EnvaptError,e as EnvaptErrorCodes};
2
2
  //# sourceMappingURL=Error.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"mDAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
1
+ {"version":3,"file":"Error.mjs","names":[],"sources":["../../../src/infra/Error.ts"],"sourcesContent":["/* eslint-disable no-magic-numbers */\nimport type { StandardSchemaV1 } from './StandardSchema';\n\n/**\n * Numeric codes carried by {@link EnvaptError.code}, grouped by fallback (1xx), converter (2xx),\n * and configuration (3xx) failures.\n */\nexport enum EnvaptErrorCodes {\n // Fallback related errors\n /** Thrown when an invalid fallback value is provided */\n InvalidFallback = 101,\n /** Thrown when fallback value type doesn't match expected converter type */\n InvalidFallbackType = 102,\n /** Thrown when array fallback contains elements of wrong type */\n ArrayFallbackElementTypeMismatch = 103,\n /** Thrown when fallback type doesn't match the specified converter */\n FallbackConverterTypeMismatch = 104,\n /** Thrown when a time-string fallback is malformed (does not match the required `<number><unit>` format) */\n MalformedTimeFallback = 105,\n\n // Converter related errors\n /** Thrown when invalid array converter configuration is provided */\n InvalidArrayConverterType = 201,\n /** Thrown when an invalid built-in converter is specified */\n InvalidBuiltInConverter = 202,\n /** Thrown when a custom converter is not a function */\n InvalidCustomConverter = 203,\n /** Thrown when converter type is not recognized */\n InvalidConverterType = 204,\n /** Thrown when primitive type coercion on fallback value fails */\n PrimitiveCoercionFailed = 205,\n /** Thrown when an array element fails to convert to the configured element type */\n ArrayElementConversionFailed = 206,\n /** Thrown under strict mode when an array element is empty or whitespace only */\n EmptyArrayElement = 207,\n /** Thrown when a Standard Schema returns issues for a non-empty env value */\n SchemaValidationFailed = 208,\n /** Thrown when a Standard Schema's `validate` itself throws (e.g. a refinement that crashes) */\n SchemaThrew = 209,\n\n // Other errors\n /** Thrown when delimiter is missing in array converter configuration */\n // This doesn't happen because 203 is thrown when object without delimiter is passed\n MissingDelimiter = 301,\n /** Thrown when invalid user-defined configuration is provided */\n InvalidUserDefinedConfig = 302,\n /** Thrown when specified environment files don't exist */\n EnvFilesNotFound = 303,\n /** Thrown when no valid environment key is provided */\n InvalidKeyInput = 304,\n /** Thrown when a required environment value is missing or empty (post-trim) */\n MissingEnvValue = 305,\n /** Thrown when a file-based API (envPaths, baseDir, configureProfiles) is used on a source without filesystem support */\n FileApiUnsupported = 306,\n /** Thrown when an environment value is read before a source is bound via Envapter.useSource */\n NoSourceBound = 307\n}\n\ninterface EnvaptErrorOptions {\n issues?: readonly StandardSchemaV1.Issue[];\n cause?: unknown;\n}\n\n/**\n * Custom error for better DX and debugging when using Envapt.\n *\n * @example\n * ```ts\n * throw new EnvaptError(EnvaptErrorCodes.InvalidFallback, \"Invalid fallback value provided for environment variable.\");\n * ```\n */\nexport class EnvaptError extends Error {\n /** The {@link EnvaptErrorCodes} value identifying what failed. */\n public readonly code: EnvaptErrorCodes;\n /**\n * Populated only for {@link EnvaptErrorCodes.SchemaValidationFailed} (208). For every other\n * code this is `undefined`. Lets callers do `if (err.code === 208) err.issues?.forEach(...)`\n * without a type cast.\n */\n public readonly issues: readonly StandardSchemaV1.Issue[] | undefined;\n\n /** Create an error carrying an {@link EnvaptErrorCodes} code, a message, and optional `cause` / `issues`. */\n constructor(code: EnvaptErrorCodes, message: string, options?: EnvaptErrorOptions) {\n super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);\n this.name = `EnvaptError [${code}]`;\n this.code = code;\n this.issues = options?.issues;\n }\n}\n"],"mappings":"AAOA,IAAY,EAAL,SAAA,EAAA,OAGH,GAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,oBAAA,KAAA,sBAEA,EAAA,EAAA,iCAAA,KAAA,mCAEA,EAAA,EAAA,8BAAA,KAAA,gCAEA,EAAA,EAAA,sBAAA,KAAA,wBAIA,EAAA,EAAA,0BAAA,KAAA,4BAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,qBAAA,KAAA,uBAEA,EAAA,EAAA,wBAAA,KAAA,0BAEA,EAAA,EAAA,6BAAA,KAAA,+BAEA,EAAA,EAAA,kBAAA,KAAA,oBAEA,EAAA,EAAA,uBAAA,KAAA,yBAEA,EAAA,EAAA,YAAA,KAAA,cAKA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,yBAAA,KAAA,2BAEA,EAAA,EAAA,iBAAA,KAAA,mBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,gBAAA,KAAA,kBAEA,EAAA,EAAA,mBAAA,KAAA,qBAEA,EAAA,EAAA,cAAA,KAAA,iBACJ,EAAA,CAAA,CAAA,EAeA,IAAa,EAAb,cAAiC,KAAM,CAEnC,KAMA,OAGA,YAAY,EAAwB,EAAiB,EAA8B,CAC/E,MAAM,EAAS,GAAS,QAAU,IAAA,GAAuC,IAAA,GAA3B,CAAE,MAAO,EAAQ,KAAM,CAAa,EAClF,KAAK,KAAO,gBAAgB,EAAK,GACjC,KAAK,KAAO,EACZ,KAAK,OAAS,GAAS,MAC3B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;let e=e=>{console.error(e)},t=()=>({});function n(t){e=t}function r(t){e(t)}function i(){return t()}function a(e){t=()=>e.readVars()}exports.bindRuntimeFromSource=a,exports.readRuntimeEnv=i,exports.setRuntimeSink=n,exports.writeRuntimeLine=r;
1
+ let e=e=>{console.error(e)},t=()=>({});function n(t){e=t}function r(t){e(t)}function i(){return t()}function a(e){t=()=>e.readVars()}exports.bindRuntimeFromSource=a,exports.readRuntimeEnv=i,exports.setRuntimeSink=n,exports.writeRuntimeLine=r;
2
2
  //# sourceMappingURL=runtime.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/infra/runtime.ts"],"sourcesContent":["import type { EnvSource } from '../types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"mDAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
1
+ {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/infra/runtime.ts"],"sourcesContent":["import type { EnvSource } from '../types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"AAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;let e=e=>{console.error(e)},t=()=>({});function n(t){e=t}function r(t){e(t)}function i(){return t()}function a(e){t=()=>e.readVars()}export{a as bindRuntimeFromSource,i as readRuntimeEnv,n as setRuntimeSink,r as writeRuntimeLine};
1
+ let e=e=>{console.error(e)},t=()=>({});function n(t){e=t}function r(t){e(t)}function i(){return t()}function a(e){t=()=>e.readVars()}export{a as bindRuntimeFromSource,i as readRuntimeEnv,n as setRuntimeSink,r as writeRuntimeLine};
2
2
  //# sourceMappingURL=runtime.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/infra/runtime.ts"],"sourcesContent":["import type { EnvSource } from '../types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"mDAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/infra/runtime.ts"],"sourcesContent":["import type { EnvSource } from '../types';\n\n// EnvapterBase imports Debug; importing it back would cycle, so the source/sink are injected via the setters below.\n/* v8 ignore start -- @preserve replaced at load on Node; the Node suite never runs these defaults */\nlet sink: (line: string) => void = (line) => {\n // eslint-disable-next-line no-console -- the off-Node fallback log sink\n console.error(line);\n};\nlet envReader: () => Record<string, string> = () => ({});\n/* v8 ignore stop */\n\nexport function setRuntimeSink(fn: (line: string) => void): void {\n sink = fn;\n}\n\nexport function writeRuntimeLine(line: string): void {\n sink(line);\n}\n\nexport function readRuntimeEnv(): Record<string, string> {\n return envReader();\n}\n\nexport function bindRuntimeFromSource(source: EnvSource): void {\n envReader = (): Record<string, string> => source.readVars();\n}\n"],"mappings":"AAIA,IAAI,EAAgC,GAAS,CAEzC,QAAQ,MAAM,CAAI,CACtB,EACI,OAAiD,CAAC,GAGtD,SAAgB,EAAe,EAAkC,CAC7D,EAAO,CACX,CAEA,SAAgB,EAAiB,EAAoB,CACjD,EAAK,CAAI,CACb,CAEA,SAAgB,GAAyC,CACrD,OAAO,EAAU,CACrB,CAEA,SAAgB,EAAsB,EAAyB,CAC3D,MAA0C,EAAO,SAAS,CAC9D"}
@@ -1 +1 @@
1
- import"node:path";import"node:url";import.meta.url,Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./decorators/legacy/Envapt.cjs"),t=require("./decorators/legacy/SugarDecorators.cjs");exports.EnvBool=t.EnvBool,exports.EnvNum=t.EnvNum,exports.EnvStr=t.EnvStr,exports.EnvTime=t.EnvTime,exports.EnvUrl=t.EnvUrl,exports.Envapt=e.Envapt;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./decorators/legacy/Envapt.cjs"),t=require("./decorators/legacy/SugarDecorators.cjs");exports.EnvBool=t.EnvBool,exports.EnvNum=t.EnvNum,exports.EnvStr=t.EnvStr,exports.EnvTime=t.EnvTime,exports.EnvUrl=t.EnvUrl,exports.Envapt=e.Envapt;
@@ -1 +1 @@
1
- import"node:path";import"node:url";import.meta.url;import{Envapt as e}from"./decorators/legacy/Envapt.mjs";import{EnvBool as t,EnvNum as n,EnvStr as r,EnvTime as i,EnvUrl as a}from"./decorators/legacy/SugarDecorators.mjs";export{t as EnvBool,n as EnvNum,r as EnvStr,i as EnvTime,a as EnvUrl,e as Envapt};
1
+ import{Envapt as e}from"./decorators/legacy/Envapt.mjs";import{EnvBool as t,EnvNum as n,EnvStr as r,EnvTime as i,EnvUrl as a}from"./decorators/legacy/SugarDecorators.mjs";export{t as EnvBool,n as EnvNum,r as EnvStr,i as EnvTime,a as EnvUrl,e as Envapt};
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;const e=require("./coerce.cjs");var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e.coerceToStringRecord(t)}readVars(){return{...this.vars}}};exports.ManualEnvSource=t;
1
+ const e=require("./coerce.cjs");var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e.coerceToStringRecord(t)}readVars(){return{...this.vars}}};exports.ManualEnvSource=t;
2
2
  //# sourceMappingURL=ManualEnvSource.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ManualEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"mFAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA+B,CACvC,KAAK,KAAOA,EAAAA,qBAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"ManualEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"gCAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA+B,CACvC,KAAK,KAAOA,EAAAA,qBAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as ManualEnvSource};
1
+ import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as ManualEnvSource};
2
2
  //# sourceMappingURL=ManualEnvSource.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ManualEnvSource.mjs","names":[],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"uGAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA+B,CACvC,KAAK,KAAO,EAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"ManualEnvSource.mjs","names":[],"sources":["../../../src/sources/ManualEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source seeded from an object you provide: the config your bundler injects into a browser\n * build (Vite's `import.meta.env`, a webpack `DefinePlugin` global), a test fixture, or any other plain\n * object. Pass it straight through; non-string values are JSON-stringified so the converters still apply.\n * It has no filesystem, so the `.env` cascade and file-based APIs do not apply.\n * @public\n */\nexport class ManualEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from `vars`. Non-string values are JSON-stringified so the converters still apply. */\n constructor(vars: Record<string, unknown>) {\n this.vars = coerceToStringRecord(vars);\n }\n\n /** Returns a snapshot clone of the provided object as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA+B,CACvC,KAAK,KAAO,EAAqB,CAAI,CACzC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:process");t=e.__toESM(t,1);let n=require("node:fs");n=e.__toESM(n,1);let r=require("node:path"),i=require("node:url");var a=class{supportsFiles=!0;readVars(){return{...t.default.env}}readFile(e,t){try{return n.default.readFileSync(e,t)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?(0,r.dirname)((0,i.fileURLToPath)(e)):(0,r.resolve)(e)}resolvePath(e,t){return(0,r.isAbsolute)(t)?t:(0,r.join)(e,t)}writeVars(e){for(let[n,r]of Object.entries(e))t.default.env[n]=r}};exports.NodeEnvSource=a;
1
+ const e=require("../_virtual/_rolldown/runtime.cjs");let t=require("node:process");t=e.__toESM(t,1);let n=require("node:fs");n=e.__toESM(n,1);let r=require("node:path"),i=require("node:url");var a=class{supportsFiles=!0;readVars(){return{...t.default.env}}readFile(e,t){try{return n.default.readFileSync(e,t)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?(0,r.dirname)((0,i.fileURLToPath)(e)):(0,r.resolve)(e)}resolvePath(e,t){return(0,r.isAbsolute)(t)?t:(0,r.join)(e,t)}writeVars(e){for(let[n,r]of Object.entries(e))t.default.env[n]=r}};exports.NodeEnvSource=a;
2
2
  //# sourceMappingURL=NodeEnvSource.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NodeEnvSource.cjs","names":["process","fs"],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n /** Always `true`. The engine layers the `.env` cascade and `baseDir` on top of `process.env`. */\n readonly supportsFiles = true;\n\n /** Returns a snapshot clone of `process.env` as plain strings. */\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n /** Reads a file with `fs.readFileSync`, or `undefined` when it is missing or unreadable. */\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n /**\n * Resolves a directory path or a module / `file:` URL to an absolute directory. A `file:` URL\n * resolves to its containing directory, and a plain path (`import.meta.dirname`, `__dirname`) is\n * taken as the directory itself.\n */\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n /** Joins a relative `.env` path onto `baseDir`. Absolute paths pass through unchanged. */\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n /** Writes each key to `process.env`, backing `Envapter.syncProcessEnv`. */\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"kPAaA,IAAa,EAAb,KAAoD,CAEhD,cAAyB,GAGzB,UAAmC,CAE/B,MAAO,CAAE,GAAIA,EAAAA,QAAQ,GAA+B,CACxD,CAGA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAOC,EAAAA,QAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAOA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,GAAG,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,cAAA,CAA6B,CAAK,CAAC,GAClE,EAAA,EAAA,QAAA,CAAe,CAAK,CACxB,CAGA,YAAY,EAAiB,EAA2B,CAEpD,OADA,EAAA,EAAA,WAAA,CAAe,CAAS,EAAU,GAClC,EAAA,EAAA,KAAA,CAAY,EAAS,CAAS,CAClC,CAGA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAA,QAAQ,IAAI,GAAO,CAE3B,CACJ"}
1
+ {"version":3,"file":"NodeEnvSource.cjs","names":["process","fs"],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n /** Always `true`. The engine layers the `.env` cascade and `baseDir` on top of `process.env`. */\n readonly supportsFiles = true;\n\n /** Returns a snapshot clone of `process.env` as plain strings. */\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n /** Reads a file with `fs.readFileSync`, or `undefined` when it is missing or unreadable. */\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n /**\n * Resolves a directory path or a module / `file:` URL to an absolute directory. A `file:` URL\n * resolves to its containing directory, and a plain path (`import.meta.dirname`, `__dirname`) is\n * taken as the directory itself.\n */\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n /** Joins a relative `.env` path onto `baseDir`. Absolute paths pass through unchanged. */\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n /** Writes each key to `process.env`, backing `Envapter.syncProcessEnv`. */\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"+LAaA,IAAa,EAAb,KAAoD,CAEhD,cAAyB,GAGzB,UAAmC,CAE/B,MAAO,CAAE,GAAIA,EAAAA,QAAQ,GAA+B,CACxD,CAGA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAOC,EAAAA,QAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAOA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,GAAG,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,cAAA,CAA6B,CAAK,CAAC,GAClE,EAAA,EAAA,QAAA,CAAe,CAAK,CACxB,CAGA,YAAY,EAAiB,EAA2B,CAEpD,OADA,EAAA,EAAA,WAAA,CAAe,CAAS,EAAU,GAClC,EAAA,EAAA,KAAA,CAAY,EAAS,CAAS,CAClC,CAGA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAA,QAAQ,IAAI,GAAO,CAE3B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;import e from"node:process";import t from"node:fs";import{dirname as n,isAbsolute as r,join as i,resolve as a}from"node:path";import{fileURLToPath as o}from"node:url";var s=class{supportsFiles=!0;readVars(){return{...e.env}}readFile(e,n){try{return t.readFileSync(e,n)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?n(o(e)):a(e)}resolvePath(e,t){return r(t)?t:i(e,t)}writeVars(t){for(let[n,r]of Object.entries(t))e.env[n]=r}};export{s as NodeEnvSource};
1
+ import e from"node:process";import t from"node:fs";import{dirname as n,isAbsolute as r,join as i,resolve as a}from"node:path";import{fileURLToPath as o}from"node:url";var s=class{supportsFiles=!0;readVars(){return{...e.env}}readFile(e,n){try{return t.readFileSync(e,n)}catch{return}}normalizeBaseDir(e){return e instanceof URL||e.startsWith(`file:`)?n(o(e)):a(e)}resolvePath(e,t){return r(t)?t:i(e,t)}writeVars(t){for(let[n,r]of Object.entries(t))e.env[n]=r}};export{s as NodeEnvSource};
2
2
  //# sourceMappingURL=NodeEnvSource.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NodeEnvSource.mjs","names":[],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n /** Always `true`. The engine layers the `.env` cascade and `baseDir` on top of `process.env`. */\n readonly supportsFiles = true;\n\n /** Returns a snapshot clone of `process.env` as plain strings. */\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n /** Reads a file with `fs.readFileSync`, or `undefined` when it is missing or unreadable. */\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n /**\n * Resolves a directory path or a module / `file:` URL to an absolute directory. A `file:` URL\n * resolves to its containing directory, and a plain path (`import.meta.dirname`, `__dirname`) is\n * taken as the directory itself.\n */\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n /** Joins a relative `.env` path onto `baseDir`. Absolute paths pass through unchanged. */\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n /** Writes each key to `process.env`, backing `Envapter.syncProcessEnv`. */\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"0NAaA,IAAa,EAAb,KAAoD,CAEhD,cAAyB,GAGzB,UAAmC,CAE/B,MAAO,CAAE,GAAI,EAAQ,GAA+B,CACxD,CAGA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAO,EAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAOA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,EAAU,EAAQ,EAAc,CAAK,CAAC,EAC3D,EAAQ,CAAK,CACxB,CAGA,YAAY,EAAiB,EAA2B,CAEpD,OADI,EAAW,CAAS,EAAU,EAC3B,EAAK,EAAS,CAAS,CAClC,CAGA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAQ,IAAI,GAAO,CAE3B,CACJ"}
1
+ {"version":3,"file":"NodeEnvSource.mjs","names":[],"sources":["../../../src/sources/NodeEnvSource.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport process from 'node:process';\nimport { fileURLToPath } from 'node:url';\n\nimport type { FileEnvSource } from '../types';\n\n/**\n * Default environment source on Node, Bun, and Deno: a snapshot of `process.env`. Its\n * `supportsFiles` is `true`, so the engine also layers the `.env` cascade on top, resolves\n * `baseDir`, and can mirror loaded keys back to `process.env`.\n * @public\n */\nexport class NodeEnvSource implements FileEnvSource {\n /** Always `true`. The engine layers the `.env` cascade and `baseDir` on top of `process.env`. */\n readonly supportsFiles = true;\n\n /** Returns a snapshot clone of `process.env` as plain strings. */\n readVars(): Record<string, string> {\n // Clone so the loader and downstream reads never mutate process.env.\n return { ...(process.env as Record<string, string>) };\n }\n\n /** Reads a file with `fs.readFileSync`, or `undefined` when it is missing or unreadable. */\n readFile(path: string, encoding: string): string | undefined {\n try {\n // justified: our public encoding type is `string`; fs needs the BufferEncoding subset.\n return fs.readFileSync(path, encoding as BufferEncoding);\n } catch {\n return undefined;\n }\n }\n\n /**\n * Resolves a directory path or a module / `file:` URL to an absolute directory. A `file:` URL\n * resolves to its containing directory, and a plain path (`import.meta.dirname`, `__dirname`) is\n * taken as the directory itself.\n */\n normalizeBaseDir(value: string | URL): string {\n if (value instanceof URL) return dirname(fileURLToPath(value));\n if (value.startsWith('file:')) return dirname(fileURLToPath(value));\n return resolve(value);\n }\n\n /** Joins a relative `.env` path onto `baseDir`. Absolute paths pass through unchanged. */\n resolvePath(baseDir: string, candidate: string): string {\n if (isAbsolute(candidate)) return candidate;\n return join(baseDir, candidate);\n }\n\n /** Writes each key to `process.env`, backing `Envapter.syncProcessEnv`. */\n writeVars(vars: Record<string, string>): void {\n for (const [key, value] of Object.entries(vars)) {\n process.env[key] = value;\n }\n }\n}\n"],"mappings":"uKAaA,IAAa,EAAb,KAAoD,CAEhD,cAAyB,GAGzB,UAAmC,CAE/B,MAAO,CAAE,GAAI,EAAQ,GAA+B,CACxD,CAGA,SAAS,EAAc,EAAsC,CACzD,GAAI,CAEA,OAAO,EAAG,aAAa,EAAM,CAA0B,CAC3D,MAAQ,CACJ,MACJ,CACJ,CAOA,iBAAiB,EAA6B,CAG1C,OAFI,aAAiB,KACjB,EAAM,WAAW,OAAO,EAAU,EAAQ,EAAc,CAAK,CAAC,EAC3D,EAAQ,CAAK,CACxB,CAGA,YAAY,EAAiB,EAA2B,CAEpD,OADI,EAAW,CAAS,EAAU,EAC3B,EAAK,EAAS,CAAS,CAClC,CAGA,UAAU,EAAoC,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAI,EAC1C,EAAQ,IAAI,GAAO,CAE3B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;const e=require("../infra/Error.cjs");var t=class{supportsFiles=!1;readVars(){throw new e.EnvaptError(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};exports.UnboundEnvSource=t;
1
+ const e=require("../infra/Error.cjs");var t=class{supportsFiles=!1;readVars(){throw new e.EnvaptError(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};exports.UnboundEnvSource=t;
2
2
  //# sourceMappingURL=UnboundEnvSource.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnboundEnvSource.cjs","names":["EnvaptError"],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"yFAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAIA,EAAAA,YAAAA,IAEN,2JACJ,CACJ,CACJ"}
1
+ {"version":3,"file":"UnboundEnvSource.cjs","names":["EnvaptError"],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"sCAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAIA,EAAAA,YAAAA,IAEN,2JACJ,CACJ,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;import{EnvaptError as e}from"../infra/Error.mjs";var t=class{supportsFiles=!1;readVars(){throw new e(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};export{t as UnboundEnvSource};
1
+ import{EnvaptError as e}from"../infra/Error.mjs";var t=class{supportsFiles=!1;readVars(){throw new e(307,`No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.`)}};export{t as UnboundEnvSource};
2
2
  //# sourceMappingURL=UnboundEnvSource.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnboundEnvSource.mjs","names":[],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"oGAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAI,EAAA,IAEN,2JACJ,CACJ,CACJ"}
1
+ {"version":3,"file":"UnboundEnvSource.mjs","names":[],"sources":["../../../src/sources/UnboundEnvSource.ts"],"sourcesContent":["import { EnvaptError, EnvaptErrorCodes } from '../infra/Error';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * The default source until one is bound. Every read throws NoSourceBound so a forgotten `useSource`\n * surfaces at read time instead of silently yielding nothing. The Node entry binds {@link NodeEnvSource}\n * at load; browser and Workers bundles must call `Envapter.useSource(...)` before reading.\n * @internal\n */\nexport class UnboundEnvSource implements BareEnvSource {\n readonly supportsFiles = false;\n\n readVars(): Record<string, string> {\n throw new EnvaptError(\n EnvaptErrorCodes.NoSourceBound,\n 'No environment source is bound. Call Envapter.useSource(...) with a source such as new ManualEnvSource({...}) or new WorkerEnvSource(env) before reading.'\n );\n }\n}\n"],"mappings":"iDAUA,IAAa,EAAb,KAAuD,CACnD,cAAyB,GAEzB,UAAmC,CAC/B,MAAM,IAAI,EAAA,IAEN,2JACJ,CACJ,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;const e=require("./coerce.cjs");var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e.coerceToStringRecord(t)}readVars(){return{...this.vars}}};exports.WorkerEnvSource=t;
1
+ const e=require("./coerce.cjs");var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e.coerceToStringRecord(t)}readVars(){return{...this.vars}}};exports.WorkerEnvSource=t;
2
2
  //# sourceMappingURL=WorkerEnvSource.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from the Workers `env` binding. Non-string values are JSON-stringified, so they must be JSON-serializable. */\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n /** Returns a snapshot clone of the `env` binding as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"mFAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA8B,CACtC,KAAK,KAAOA,EAAAA,qBAAqB,CAAG,CACxC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"WorkerEnvSource.cjs","names":["coerceToStringRecord"],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from the Workers `env` binding. Non-string values are JSON-stringified, so they must be JSON-serializable. */\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n /** Returns a snapshot clone of the `env` binding as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"gCAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA8B,CACtC,KAAK,KAAOA,EAAAA,qBAAqB,CAAG,CACxC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as WorkerEnvSource};
1
+ import{coerceToStringRecord as e}from"./coerce.mjs";var t=class{supportsFiles=!1;vars;constructor(t){this.vars=e(t)}readVars(){return{...this.vars}}};export{t as WorkerEnvSource};
2
2
  //# sourceMappingURL=WorkerEnvSource.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerEnvSource.mjs","names":[],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from the Workers `env` binding. Non-string values are JSON-stringified, so they must be JSON-serializable. */\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n /** Returns a snapshot clone of the `env` binding as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"uGAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA8B,CACtC,KAAK,KAAO,EAAqB,CAAG,CACxC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
1
+ {"version":3,"file":"WorkerEnvSource.mjs","names":[],"sources":["../../../src/sources/WorkerEnvSource.ts"],"sourcesContent":["import { coerceToStringRecord } from './coerce';\n\nimport type { BareEnvSource } from '../types';\n\n/**\n * Environment source for Cloudflare Workers, seeded from the `env` binding. String bindings pass\n * through; non-string bindings are JSON-stringified so the converters still apply, and so must be\n * JSON-serializable (a `bigint` or circular value throws). No filesystem, so the `.env` cascade and\n * file-based APIs do not apply.\n * @public\n */\nexport class WorkerEnvSource implements BareEnvSource {\n /** Always `false`. With no filesystem, the `.env` cascade and file APIs do not apply. */\n readonly supportsFiles = false;\n private readonly vars: Record<string, string>;\n\n /** Seed the source from the Workers `env` binding. Non-string values are JSON-stringified, so they must be JSON-serializable. */\n constructor(env: Record<string, unknown>) {\n this.vars = coerceToStringRecord(env);\n }\n\n /** Returns a snapshot clone of the `env` binding as plain strings. */\n readVars(): Record<string, string> {\n return { ...this.vars };\n }\n}\n"],"mappings":"oDAWA,IAAa,EAAb,KAAsD,CAElD,cAAyB,GACzB,KAGA,YAAY,EAA8B,CACtC,KAAK,KAAO,EAAqB,CAAG,CACxC,CAGA,UAAmC,CAC/B,MAAO,CAAE,GAAG,KAAK,IAAK,CAC1B,CACJ"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;function e(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r==`string`){t[n]=r;continue}let e=JSON.stringify(r);e!==void 0&&(t[n]=e)}return t}exports.coerceToStringRecord=e;
1
+ function e(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r==`string`){t[n]=r;continue}let e=JSON.stringify(r);e!==void 0&&(t[n]=e)}return t}exports.coerceToStringRecord=e;
2
2
  //# sourceMappingURL=coerce.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"coerce.cjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"mDAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
1
+ {"version":3,"file":"coerce.cjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"AAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
@@ -1,2 +1,2 @@
1
- import"node:path";import"node:url";import.meta.url;function e(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r==`string`){t[n]=r;continue}let e=JSON.stringify(r);e!==void 0&&(t[n]=e)}return t}export{e as coerceToStringRecord};
1
+ function e(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r==`string`){t[n]=r;continue}let e=JSON.stringify(r);e!==void 0&&(t[n]=e)}return t}export{e as coerceToStringRecord};
2
2
  //# sourceMappingURL=coerce.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"coerce.mjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"mDAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
1
+ {"version":3,"file":"coerce.mjs","names":[],"sources":["../../../src/sources/coerce.ts"],"sourcesContent":["// Shared by ManualEnvSource and WorkerEnvSource. The returned record is fresh, so a caller mutating its\n// object later can't leak into the source; non-string values are JSON-stringified.\nexport function coerceToStringRecord(env: Record<string, unknown>): Record<string, string> {\n const snapshot: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (typeof value === 'string') {\n snapshot[key] = value;\n continue;\n }\n const encoded = JSON.stringify(value);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TS lib mistypes JSON.stringify's return as always-string; it is string | undefined at runtime\n if (encoded !== undefined) snapshot[key] = encoded;\n }\n return snapshot;\n}\n"],"mappings":"AAEA,SAAgB,EAAqB,EAAsD,CACvF,IAAM,EAAmC,CAAC,EAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EAAG,CAC5C,GAAI,OAAO,GAAU,SAAU,CAC3B,EAAS,GAAO,EAChB,QACJ,CACA,IAAM,EAAU,KAAK,UAAU,CAAK,EAEhC,IAAY,IAAA,KAAW,EAAS,GAAO,EAC/C,CACA,OAAO,CACX"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "7.0.1",
4
+ "version": "7.0.2",
5
5
  "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/types/index.d.mts",
7
7
  "exports": {
@@ -171,6 +171,7 @@
171
171
  "test:consumer-build": "node tests/consumer-build/run.mjs",
172
172
  "test:tree-shaking": "node tests/tree-shaking/run.mjs",
173
173
  "test:exports-dedup": "node tests/exports-dedup/run.mjs",
174
+ "test:cjs-validity": "node tests/cjs-validity/run.mjs",
174
175
  "test:tsc-emit": "node tests/tsc-emit/run.mjs",
175
176
  "test:stage3-emit": "node tests/stage3-emit/run.mjs",
176
177
  "test:all": "node ../../scripts/test-all.mjs",
@@ -178,8 +179,8 @@
178
179
  "cs": "changeset",
179
180
  "cs:publish": "changeset publish",
180
181
  "cs:status": "changeset status",
181
- "bump": "pnpm tsx ../../scripts/bump-jsr.ts",
182
+ "bump": "pnpm tsx ../../scripts/release/bump-jsr.ts",
182
183
  "release": "pnpm run cs:publish"
183
184
  },
184
- "readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to read typed config.</strong><br/>\n Read config from any source as real typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\nenvapt returns config as the type you asked for instead of the `string | undefined` you get raw, with\na fallback that removes `undefined` from the return type. It reads from whatever source you bind. On\nNode, Bun, and Deno that is `process.env` and your `.env` files, bound on import. On Cloudflare\nWorkers, in the browser, or for a secrets object you fetched at boot, you bind the source with\n`Envapter.useSource(...)`.\n\n```ts\nimport { Envapter } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000); // number, not string | undefined\n```\n\n**[Read the docs →](https://envapt.materwelon.dev)**\n\n## What you get\n\n- **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover\n numbers, booleans, bigint, JSON, URLs, regular expressions, dates, durations, and arrays, or pass\n your own function or a Standard Schema validator (zod, valibot, arktype).\n- **Any source.** A source is any object with a `readVars()` method, so you can bind `process.env`, a\n Cloudflare Workers binding, a browser bundle, or a secrets payload you fetched from a store at boot.\n On Node, Bun, and Deno one binds on import.\n- **Zero runtime dependencies.** The reader, converters, and built-in `.env` parser are self-contained,\n so nothing is added to your dependency tree.\n- **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3`, Deno\n `>=2.5` (ESM and CJS). The Workers and browser builds resolve through the package `exports`\n conditions.\n- **`.env` loading built in on Node.** The default Node source adds a per-environment file cascade,\n `${VAR}` templates, and strict / required checks. Off Node there is no filesystem, so you bind\n another source with `Envapter.useSource(...)` and read with the same typed API.\n\n## Install\n\n```sh\nnpm install envapt\npnpm add envapt\nyarn add envapt\nbun add envapt\ndeno add jsr:@materwelon/envapt\n```\n\n## Quick start\n\nRead values functionally with `Envapter`, or bind them to class fields with the `@Envapt` decorator.\nBoth share the same parsing, converters, and cache.\n\n### Functional\n\nRead a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is\nbound for you. On Workers and in the browser, call `Envapter.useSource(...)` first.\n\n```ts\nimport { Envapter, Converters } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000);\nconst origins = Envapter.getUsing('ALLOWED_ORIGINS', Converters.array(), []);\n```\n\nOn Cloudflare Workers, `env` is importable at module scope, so bind it once in a config module; in the\nbrowser, seed a `ManualEnvSource` from the object your bundler injects.\n\n```ts\nimport { env } from 'cloudflare:workers';\nimport { Envapter, WorkerEnvSource } from 'envapt';\n\nEnvapter.useSource(new WorkerEnvSource(env));\n\nexport const apiToken = Envapter.get('API_TOKEN');\n```\n\n### Decorator\n\nBind a value to a class field with a TC39 accessor decorator. No `experimentalDecorators` flag, and it runs on Bun and Deno from `.ts` directly.\n\n```ts\nimport { EnvNum, Converters } from 'envapt';\n\nclass Config {\n @EnvNum('PORT', 3000)\n static accessor port: number;\n}\n```\n\nThe legacy (experimentalDecorators) decorators are exported from `envapt/legacy`.\n\n## Agent skill\n\nInstall the envapt agent skill so AI coding tools use the correct API:\n\n```sh\nnpx skills add materwelonDhruv/envapt\n```\n\n---\n\n<p align=\"center\"><sub>Built by <a href=\"https://github.com/materwelondhruv\">@materwelonDhruv</a> · Apache 2.0</sub></p>\n"
185
+ "readme": "<img src=\"https://raw.githubusercontent.com/materwelonDhruv/envapt/main/.github/assets/logo.png\" width=\"120\" align=\"left\" alt=\"envapt logo\" />\n\n<h3>envapt</h3>\n\n<p>\n <strong>The apt way to read typed config.</strong><br/>\n Read config from any source as real typed values, with zero runtime dependencies.\n</p>\n\n<p>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"npm\" src=\"https://img.shields.io/npm/v/envapt?logo=npm&logoColor=cb3838&label=%20&labelColor=103544&color=cb3838\"></a>\n <a href=\"https://www.npmjs.com/package/envapt\"><img alt=\"downloads\" src=\"https://img.shields.io/npm/dm/envapt?style=flat&color=f7f6e8&labelColor=103544&label=downloads\"></a>\n <a href=\"https://jsr.io/@materwelon/envapt\"><img alt=\"jsr\" src=\"https://jsr.io/badges/@materwelon/envapt\"></a>\n <img alt=\"CI\" src=\"https://img.shields.io/github/actions/workflow/status/materwelonDhruv/envapt/checks.yml?branch=main&label=tests&style=flat&logo=github&color=3fb950&labelColor=103544\">\n <a href=\"LICENSE\"><img alt=\"License\" src=\"https://img.shields.io/npm/l/envapt?style=flat&color=e97826&logo=apache&label=\"></a>\n</p>\n\n<br clear=\"left\"/>\n\nenvapt returns config as the type you asked for instead of the `string | undefined` you get raw, with\na fallback that removes `undefined` from the return type. It reads from whatever source you bind. On\nNode, Bun, and Deno that is `process.env` and your `.env` files, bound on import. On Cloudflare\nWorkers, in the browser, or for a secrets object you fetched at boot, you bind the source with\n`Envapter.useSource(...)`.\n\n```ts\nimport { Envapter } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000); // number, not string | undefined\n```\n\n**[Read the docs →](https://envapt.materwelon.dev)**\n\n## What you get\n\n- **Typed values.** A fallback removes `undefined` from the return type. Built-in converters cover\n numbers, booleans, bigint, JSON, URLs, regular expressions, dates, durations, and arrays, or pass\n your own function or a Standard Schema validator (zod, valibot, arktype).\n- **Any source.** A source is any object with a `readVars()` method, so you can bind `process.env`, a\n Cloudflare Workers binding, a browser bundle, or a secrets payload you fetched from a store at boot.\n On Node, Bun, and Deno one binds on import.\n- **Zero runtime dependencies.** The reader, converters, and built-in `.env` parser are self-contained,\n so nothing is added to your dependency tree.\n- **Runs on Node, Bun, Deno, Cloudflare Workers, and the browser.** Node `>=20`, Bun `>=1.3`, Deno\n `>=2.5` (ESM and CJS). The Workers and browser builds resolve through the package `exports`\n conditions.\n- **`.env` loading built in on Node.** The default Node source adds a per-environment file cascade,\n `${VAR}` templates, and strict / required checks. Off Node there is no filesystem, so you bind\n another source with `Envapter.useSource(...)` and read with the same typed API.\n\n## Install\n\n```sh\nnpm install envapt\npnpm add envapt\nyarn add envapt\nbun add envapt\ndeno add jsr:@materwelon/envapt\n```\n\n## Quick start\n\nRead values functionally with `Envapter`, or bind them to class fields with the `@Envapt` decorator.\nBoth share the same parsing, converters, and cache.\n\n### Functional\n\nRead a value from any call site, in JavaScript or TypeScript. No build step. On Node the source is\nbound for you. On Workers and in the browser, call `Envapter.useSource(...)` first.\n\n```ts\nimport { Envapter, Converters } from 'envapt';\n\nconst port = Envapter.getNumber('PORT', 3000);\nconst origins = Envapter.getUsing('ALLOWED_ORIGINS', Converters.array(), []);\n```\n\nOn Cloudflare Workers, `env` is importable at module scope, so bind it once in a config module; in the\nbrowser, seed a `ManualEnvSource` from the object your bundler injects.\n\n```ts\nimport { env } from 'cloudflare:workers';\nimport { Envapter, WorkerEnvSource } from 'envapt';\n\nEnvapter.useSource(new WorkerEnvSource(env));\n\nexport const apiToken = Envapter.get('API_TOKEN');\n```\n\n### Decorator\n\nBind a value to a class field with a TC39 accessor decorator. No `experimentalDecorators` flag, and it runs on Bun and Deno from `.ts` directly.\n\n```ts\nimport { EnvNum } from 'envapt';\n\nclass Config {\n @EnvNum('PORT', 3000)\n static accessor port: number;\n}\n```\n\nThe legacy (experimentalDecorators) decorators are exported from `envapt/legacy`.\n\n## Agent skill\n\nInstall the envapt agent skill so AI coding tools use the correct API:\n\n```sh\nnpx skills add materwelonDhruv/envapt\n```\n\n---\n\n<p align=\"center\"><sub>Built by <a href=\"https://github.com/materwelondhruv\">@materwelonDhruv</a> · Apache 2.0</sub></p>\n"
185
186
  }