@arkenv/nextjs 1.0.0-alpha.0 → 1.0.0-alpha.1

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 (55) hide show
  1. package/dist/arkenv-internal-DA4LpI3t.cjs +2 -0
  2. package/dist/arkenv-internal-DA4LpI3t.cjs.map +1 -0
  3. package/dist/arkenv-internal-cagrxXTM.js +2 -0
  4. package/dist/arkenv-internal-cagrxXTM.js.map +1 -0
  5. package/dist/client.cjs +1 -1
  6. package/dist/client.cjs.map +1 -1
  7. package/dist/client.d.cts +3 -4
  8. package/dist/client.d.cts.map +1 -1
  9. package/dist/client.d.ts +3 -4
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +1 -1
  12. package/dist/client.js.map +1 -1
  13. package/dist/config.cjs +6 -8
  14. package/dist/config.cjs.map +1 -1
  15. package/dist/config.d.cts.map +1 -1
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js +6 -8
  18. package/dist/config.js.map +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +2 -8
  22. package/dist/index.d.cts.map +1 -1
  23. package/dist/index.d.ts +2 -8
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/react-server.cjs +1 -1
  28. package/dist/react-server.cjs.map +1 -1
  29. package/dist/react-server.d.cts +2 -8
  30. package/dist/react-server.d.cts.map +1 -1
  31. package/dist/react-server.d.ts +2 -8
  32. package/dist/react-server.d.ts.map +1 -1
  33. package/dist/react-server.js +1 -1
  34. package/dist/react-server.js.map +1 -1
  35. package/dist/server.cjs +1 -1
  36. package/dist/server.cjs.map +1 -1
  37. package/dist/server.d.cts +3 -4
  38. package/dist/server.d.cts.map +1 -1
  39. package/dist/server.d.ts +3 -4
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +1 -1
  42. package/dist/server.js.map +1 -1
  43. package/dist/shared.cjs +1 -1
  44. package/dist/shared.cjs.map +1 -1
  45. package/dist/shared.d.cts +2 -3
  46. package/dist/shared.d.cts.map +1 -1
  47. package/dist/shared.d.ts +2 -3
  48. package/dist/shared.d.ts.map +1 -1
  49. package/dist/shared.js +1 -1
  50. package/dist/shared.js.map +1 -1
  51. package/package.json +2 -2
  52. package/dist/create-env-BfXQtLQM.js +0 -2
  53. package/dist/create-env-BfXQtLQM.js.map +0 -1
  54. package/dist/create-env-DDWVuzwL.cjs +0 -2
  55. package/dist/create-env-DDWVuzwL.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["chokidarWatch"],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { watch as chokidarWatch } from \"chokidar\";\n\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __arkenv_watcher__: import(\"chokidar\").FSWatcher | undefined;\n}\n\n/**\n * Configuration options for the ArkEnv Next.js integration.\n *\n * @example\n * ```ts\n * const configOptions: ArkEnvConfigOptions = {\n * schemaPath: \"./src/env.ts\",\n * outputPath: \"./src/generated/env.gen.ts\"\n * };\n * ```\n */\nexport type ArkEnvConfigOptions = {\n\t/**\n\t * Specify the path to the schema definition file.\n\t *\n\t * Defaults to searching for `\"src/env.ts\"` or `\"env.ts\"` in the project root.\n\t *\n\t * @default \"src/env.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * schemaPath: \"./src/env.ts\"\n\t * });\n\t * ```\n\t */\n\tschemaPath?: string;\n\n\t/**\n\t * Specify the path where the generated file (`env.gen.ts`) should be written.\n\t *\n\t * Defaults to `\"generated/env.gen.ts\"` in the same directory as the schema file.\n\t *\n\t * @default \"[schemaDirectory]/generated/env.gen.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * outputPath: \"./src/generated/env.gen.ts\"\n\t * });\n\t * ```\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Specify the configuration layout.\n\t *\n\t * - `\"simple\"` (default): A single `env.ts` schema file.\n\t * - `\"strict\"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).\n\t *\n\t * @default \"simple\"\n\t */\n\tlayout?: \"simple\" | \"strict\";\n};\n\n/**\n * Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.\n *\n * @param nextConfig The Next.js configuration object or function\n * @param options Optional configuration paths for schema and output files\n * @returns The Next.js configuration object unchanged\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T {\n\t// 1. Locate the env.ts schema file or strict schema directory\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\t// Auto-detect layout if not specified\n\tlet exists = false;\n\tif (schemaPath) {\n\t\tif (fs.existsSync(schemaPath)) {\n\t\t\texists = true;\n\t\t} else {\n\t\t\tconst ext = path.extname(schemaPath);\n\t\t\tif (ext) {\n\t\t\t\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\t\t\t\tif (fs.existsSync(baseWithoutExt)) {\n\t\t\t\t\texists = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!schemaPath || !exists) {\n\t\tthrow new Error(\n\t\t\t`[ArkEnv] Could not find schema file at ${\n\t\t\t\toptions?.schemaPath || \"src/env.ts or env.ts\"\n\t\t\t}. Please specify 'schemaPath' in withArkEnv options.`,\n\t\t);\n\t}\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\toptions?.layout,\n\t);\n\n\t// 2. Determine outputPath (defaults to generated/env.gen.ts in the same directory as schemaPath/baseDir)\n\tconst defaultOutputDir =\n\t\tresolvedLayout === \"strict\" && baseDir ? baseDir : path.dirname(schemaPath);\n\tconst defaultOutputPath = path.join(\n\t\tdefaultOutputDir,\n\t\t\"generated\",\n\t\t\"env.gen.ts\",\n\t);\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\t// 3. Run initial code generation\n\ttry {\n\t\trunCodegen(schemaPath, outputPath, resolvedLayout);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`[ArkEnv] Failed to generate env.gen.ts: ${message}`);\n\t}\n\n\t// 4. Initialize development file watcher if in dev mode\n\tconst isDev =\n\t\tprocess.env.NODE_ENV === \"development\" ||\n\t\tprocess.env.NEXT_PHASE === \"phase-development-server\";\n\tif (isDev) {\n\t\tconst watchPaths =\n\t\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t\t? [\n\t\t\t\t\t\tpath.join(baseDir, \"internal\", \"shared.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"client.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"server.ts\"),\n\t\t\t\t\t].filter(fs.existsSync)\n\t\t\t\t: [schemaPath];\n\t\twatchSchema(watchPaths, outputPath, resolvedLayout);\n\t}\n\n\treturn nextConfig;\n}\n\n/**\n * Find the path to the schema file in the project.\n *\n * @returns The absolute path to the schema file, or null if not found\n */\n/**\n * Resolve the layout (simple vs strict) and the base directory from a schema path.\n *\n * Auto-detects layout when `layoutOption` is not provided. When `layoutOption`\n * is `\"strict\"`, validates that the required split files exist and throws a\n * descriptive error if either is missing.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param layoutOption The explicit layout option, if provided\n * @returns The resolved layout and base directory\n * @throws An error if strict layout files are missing\n */\nfunction resolveLayout(\n\tschemaPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n): { layout: \"simple\" | \"strict\"; baseDir: string } {\n\tconst checkStrict = (dir: string) =>\n\t\tfs.existsSync(path.join(dir, \"internal\", \"shared.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"client.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"server.ts\"));\n\n\tconst resolveBaseDir = (p: string): string => {\n\t\t// Normalize: if schemaPath has an extension, try the extensionless form as a dir\n\t\tconst ext = path.extname(p);\n\t\tconst baseWithoutExt = ext ? p.slice(0, -ext.length) : p;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory()\n\t\t) {\n\t\t\treturn baseWithoutExt;\n\t\t}\n\t\treturn p;\n\t};\n\n\tif (!layoutOption) {\n\t\t// Auto-detect\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tif (checkStrict(resolved)) {\n\t\t\t\treturn { layout: \"strict\", baseDir: resolved };\n\t\t\t}\n\t\t\treturn { layout: \"simple\", baseDir: resolved };\n\t\t}\n\n\t\t// schemaPath is a file — check surrounding dirs\n\t\tconst parent = path.dirname(schemaPath);\n\t\tconst ext = path.extname(schemaPath);\n\t\tconst baseWithoutExt = ext ? schemaPath.slice(0, -ext.length) : schemaPath;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory() &&\n\t\t\tcheckStrict(baseWithoutExt)\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: baseWithoutExt };\n\t\t}\n\t\tif (checkStrict(parent)) {\n\t\t\treturn { layout: \"strict\", baseDir: parent };\n\t\t}\n\t\tif (\n\t\t\tpath.basename(parent) === \"internal\" &&\n\t\t\tcheckStrict(path.dirname(parent))\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: path.dirname(parent) };\n\t\t}\n\t\treturn { layout: \"simple\", baseDir: schemaPath };\n\t}\n\n\tif (layoutOption === \"strict\") {\n\t\t// Resolve baseDir for an explicit strict layout\n\t\tlet baseDir: string;\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tbaseDir = resolved;\n\t\t} else {\n\t\t\tconst parent = path.dirname(schemaPath);\n\t\t\tif (path.basename(parent) === \"internal\") {\n\t\t\t\tbaseDir = path.dirname(parent);\n\t\t\t} else {\n\t\t\t\tbaseDir = parent;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that required split files exist\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\t\tif (!fs.existsSync(clientPath) || !fs.existsSync(sharedPath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`[ArkEnv] Strict layout requires \"${clientPath}\" and \"${sharedPath}\" to exist. ` +\n\t\t\t\t\t`Ensure both files are present or remove the 'layout: \"strict\"' option to let ArkEnv auto-detect.`,\n\t\t\t);\n\t\t}\n\n\t\treturn { layout: \"strict\", baseDir };\n\t}\n\n\t// layoutOption === \"simple\"\n\treturn { layout: \"simple\", baseDir: schemaPath };\n}\n\nfunction findSchemaPath(): string | null {\n\tconst possiblePaths = [\n\t\tpath.join(process.cwd(), \"src\", \"env.ts\"),\n\t\tpath.join(process.cwd(), \"env.ts\"),\n\t];\n\tfor (const p of possiblePaths) {\n\t\tif (fs.existsSync(p)) return p;\n\t}\n\n\tconst possibleDirs = [\n\t\tpath.join(process.cwd(), \"src\", \"env\"),\n\t\tpath.join(process.cwd(), \"env\"),\n\t];\n\tfor (const d of possibleDirs) {\n\t\tif (\n\t\t\tfs.existsSync(d) &&\n\t\t\tfs.existsSync(path.join(d, \"internal\", \"shared.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"client.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"server.ts\"))\n\t\t) {\n\t\t\treturn d;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Watch the schema file for changes and trigger codegen.\n *\n * @param schemaPath The absolute path to the schema file, or an array of paths to watch\n * @param outputPath The absolute path to the generated output file\n * @param layout The resolved layout to pass through to codegen on each change\n */\nfunction watchSchema(\n\tschemaPath: string | string[],\n\toutputPath: string,\n\tlayout?: \"simple\" | \"strict\",\n) {\n\tconst previousWatcher = globalThis.__arkenv_watcher__;\n\tif (previousWatcher && typeof previousWatcher.close === \"function\") {\n\t\tpreviousWatcher.close().catch((err: unknown) => {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\tconsole.error(\n\t\t\t\t`[ArkEnv Watcher] Failed to close previous watcher: ${message}`,\n\t\t\t);\n\t\t});\n\t}\n\n\ttry {\n\t\tconst watcher = chokidarWatch(schemaPath, { ignoreInitial: true });\n\t\tglobalThis.__arkenv_watcher__ = watcher;\n\n\t\twatcher.on(\"change\", () => {\n\t\t\ttry {\n\t\t\t\tconst mainSchemaPath = Array.isArray(schemaPath)\n\t\t\t\t\t? schemaPath[0]\n\t\t\t\t\t: schemaPath;\n\t\t\t\trunCodegen(mainSchemaPath, outputPath, layout);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[ArkEnv Watcher] Failed to regenerate env.gen.ts: ${message}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t} catch (err: unknown) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\tconsole.error(\n\t\t\t`[ArkEnv Watcher] Failed to start watch on ${schemaPath}: ${message}`,\n\t\t);\n\t}\n}\n\n/**\n * Run code generation to read the schema file and generate the env.gen.ts factory.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param outputPath The absolute path to the generated output file\n * @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted\n * @throws An error if strict layout files are missing when `layoutOption` is `\"strict\"`\n */\nexport function runCodegen(\n\tschemaPath: string,\n\toutputPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n) {\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tlayoutOption,\n\t);\n\n\tlet generatedCode = \"\";\n\tif (resolvedLayout === \"strict\") {\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\n\t\tconst clientContent = fs.existsSync(clientPath)\n\t\t\t? fs.readFileSync(clientPath, \"utf-8\")\n\t\t\t: \"\";\n\t\tconst sharedContent = fs.existsSync(sharedPath)\n\t\t\t? fs.readFileSync(sharedPath, \"utf-8\")\n\t\t\t: \"\";\n\n\t\tconst clientKeys = extractClientKeys(clientContent);\n\t\tconst sharedKeys = extractSharedKeys(sharedContent);\n\n\t\tgeneratedCode = generateClientFactoryCode(clientKeys, sharedKeys);\n\t} else {\n\t\tconst fileContent = fs.readFileSync(schemaPath, \"utf-8\");\n\t\tconst { clientKeys, sharedKeys } = extractKeys(fileContent);\n\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys);\n\t}\n\n\t// Ensure parent directory exists\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\n\t// Write if changed to avoid unnecessary filesystem/watcher triggers\n\tlet shouldWrite = true;\n\tif (fs.existsSync(outputPath)) {\n\t\tconst existingContent = fs.readFileSync(outputPath, \"utf-8\");\n\t\tif (existingContent === generatedCode) {\n\t\t\tshouldWrite = false;\n\t\t}\n\t}\n\n\tif (shouldWrite) {\n\t\tfs.writeFileSync(outputPath, generatedCode, \"utf-8\");\n\t}\n}\n\n/**\n * Statically extract client and shared keys from the schema content.\n *\n * @param content The schema file string content\n * @returns An object containing the extracted client and shared keys\n */\nexport function extractKeys(content: string): {\n\tclientKeys: string[];\n\tsharedKeys: string[];\n} {\n\tconst clientKeys: string[] = [];\n\tconst sharedKeys: string[] = [];\n\n\t// Extract client block\n\tconst clientBlock = extractBlock(content, \"client\");\n\tif (clientBlock) {\n\t\tclientKeys.push(...parseBlockKeys(clientBlock));\n\t}\n\n\t// Extract shared block\n\tconst sharedBlock = extractBlock(content, \"shared\");\n\tif (sharedBlock) {\n\t\tsharedKeys.push(...parseBlockKeys(sharedBlock));\n\t}\n\n\treturn { clientKeys, sharedKeys };\n}\n\n/**\n * Extract a specific block from the schema content by name.\n *\n * @param content The schema file string content\n * @param blockName The name of the block to extract (e.g., 'client' or 'shared')\n * @returns The contents of the block, or null if not found\n */\nfunction extractBlock(content: string, blockName: string): string | null {\n\t// Find \"\\bblockName\\s*:\\s*{\" or \"\\bblockName\\s*:\\s*type({\"\n\tconst regex = new RegExp(\n\t\t`\\\\b${blockName}\\\\s*:\\\\s*(?:[a-zA-Z0-9_$.]+\\\\s*\\\\(\\\\s*)?\\\\{`,\n\t\t\"g\",\n\t);\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Parse environment variable keys from a block's content.\n *\n * @param blockContent The raw content of the block\n * @returns An array of parsed environment variable keys\n */\nfunction parseBlockKeys(blockContent: string): string[] {\n\tconst keys: string[] = [];\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\tlet currentToken = \"\";\n\tlet lastStringContent = \"\";\n\tlet braceDepth = 0;\n\n\tfor (let i = 0; i < blockContent.length; i++) {\n\t\tconst char = blockContent[i];\n\t\tconst nextChar = blockContent[i + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && blockContent[i - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t\tlastStringContent = currentToken;\n\t\t\t\tcurrentToken = \"\";\n\t\t\t} else {\n\t\t\t\tcurrentToken += char;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Start comments/strings\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tcurrentToken = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceDepth++;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"}\") {\n\t\t\tbraceDepth--;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \":\") {\n\t\t\tif (braceDepth === 0) {\n\t\t\t\tconst key = currentToken.trim() || lastStringContent.trim();\n\t\t\t\tif (key) {\n\t\t\t\t\tkeys.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (/[a-zA-Z0-9_$]/.test(char)) {\n\t\t\tcurrentToken += char;\n\t\t} else if (char === \",\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t}\n\t}\n\n\treturn keys;\n}\n\n/**\n * Generate the TypeScript factory code for the tailored createEnv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @returns The generated TypeScript source code string\n */\nfunction generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs\";\nimport type { Infer } from \"@arkenv/nextjs\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function createEnv<\n\tconst TServer extends Record<string, any> = {},\n\tconst TClient extends Record<string, any> = {},\n\tconst TShared extends Record<string, any> = {},\n>(options: {\n\tserver?: TServer;\n\tclient?: TClient & {\n\t\t[K in keyof TClient]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t};\n\tshared?: TShared;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\treturn coreCreateEnv({\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any) as any;\n}\n\nconst arkenv = createEnv;\nexport default arkenv;\n`;\n}\n\n/**\n * Generate the TypeScript factory code for the strict-layout `createEnv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @returns The generated TypeScript source code string\n */\nfunction generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs/client\";\n\nexport { type } from \"@arkenv/nextjs/client\";\n\nexport function createEnv<\n\tconst TSchema extends Record<string, any> = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema & {\n\t\t[K in keyof TSchema]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t},\n\toptions?: {\n\t\textends?: [...TExtends];\n\t},\n) {\n\treturn coreCreateEnv<TSchema, TExtends>(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);\n}\n\nconst arkenv = createEnv;\nexport default arkenv;\n`;\n}\n\n/**\n * Extract env var keys from a strict-layout `client.ts` file.\n *\n * Locates the first `arkenv({...})` call and delegates to `parseBlockKeys`\n * to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `client.ts`\n * @returns An array of env var key names found in the client schema\n */\nexport function extractClientKeys(content: string): string[] {\n\tconst block = extractClientBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract env var keys from a strict-layout `internal/shared.ts` file.\n *\n * Locates the `SharedSchema = ...({...})` assignment and delegates to\n * `parseBlockKeys` to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns An array of env var key names found in the shared schema\n */\nexport function extractSharedKeys(content: string): string[] {\n\tconst block = extractSharedBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract the schema object body from a strict-layout `client.ts` file.\n *\n * Matches the first `arkenv(...)` call, then performs brace-balanced\n * traversal while respecting strings and comments to find the boundaries\n * of the first argument object.\n *\n * @param content The source text of `client.ts`\n * @returns The raw text inside the first `{...}` argument, or `null` if not found\n */\nfunction extractClientBlock(content: string): string | null {\n\tconst regex = /\\barkenv\\s*\\(\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract the schema object body from a strict-layout `internal/shared.ts` file.\n *\n * Matches the `SharedSchema = ...({...})` assignment, then performs\n * brace-balanced traversal while respecting strings and comments to find\n * the boundaries of the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns The raw text inside the `{...}` schema object, or `null` if not found\n */\nfunction extractSharedBlock(content: string): string | null {\n\tconst regex = /\\bSharedSchema\\s*=\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n"],"mappings":"iFAsEA,SAAgB,EAAc,EAAe,EAAkC,CAE9E,IAAM,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,GAAgB,CAGf,EAAS,GACb,GAAI,EACH,GAAI,EAAG,WAAW,EAAW,CAC5B,EAAS,OACH,CACN,IAAM,EAAM,EAAK,QAAQ,EAAW,CACpC,GAAI,EAAK,CACR,IAAM,EAAiB,EAAW,MAAM,EAAG,CAAC,EAAI,OAAO,CACnD,EAAG,WAAW,EAAe,GAChC,EAAS,KAMb,GAAI,CAAC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ACjD,EAAW,EACX,IACA,SAGG,IAAS,IACZ,IACU,IAAS,KACnB,IAED,IAOD,OAJI,IAAe,EACX,EAAQ,MAAM,EAAY,EAAQ,EAAE,CAGrC"}
1
+ {"version":3,"file":"config.js","names":["chokidarWatch"],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { watch as chokidarWatch } from \"chokidar\";\n\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __arkenv_watcher__: import(\"chokidar\").FSWatcher | undefined;\n}\n\n/**\n * Configuration options for the ArkEnv Next.js integration.\n *\n * @example\n * ```ts\n * const configOptions: ArkEnvConfigOptions = {\n * schemaPath: \"./src/env.ts\",\n * outputPath: \"./src/generated/env.gen.ts\"\n * };\n * ```\n */\nexport type ArkEnvConfigOptions = {\n\t/**\n\t * Specify the path to the schema definition file.\n\t *\n\t * Defaults to searching for `\"src/env.ts\"` or `\"env.ts\"` in the project root.\n\t *\n\t * @default \"src/env.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * schemaPath: \"./src/env.ts\"\n\t * });\n\t * ```\n\t */\n\tschemaPath?: string;\n\n\t/**\n\t * Specify the path where the generated file (`env.gen.ts`) should be written.\n\t *\n\t * Defaults to `\"generated/env.gen.ts\"` in the same directory as the schema file.\n\t *\n\t * @default \"[schemaDirectory]/generated/env.gen.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * outputPath: \"./src/generated/env.gen.ts\"\n\t * });\n\t * ```\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Specify the configuration layout.\n\t *\n\t * - `\"simple\"` (default): A single `env.ts` schema file.\n\t * - `\"strict\"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).\n\t *\n\t * @default \"simple\"\n\t */\n\tlayout?: \"simple\" | \"strict\";\n};\n\n/**\n * Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.\n *\n * @param nextConfig The Next.js configuration object or function\n * @param options Optional configuration paths for schema and output files\n * @returns The Next.js configuration object unchanged\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T {\n\t// 1. Locate the env.ts schema file or strict schema directory\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\t// Auto-detect layout if not specified\n\tlet exists = false;\n\tif (schemaPath) {\n\t\tif (fs.existsSync(schemaPath)) {\n\t\t\texists = true;\n\t\t} else {\n\t\t\tconst ext = path.extname(schemaPath);\n\t\t\tif (ext) {\n\t\t\t\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\t\t\t\tif (fs.existsSync(baseWithoutExt)) {\n\t\t\t\t\texists = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!schemaPath || !exists) {\n\t\tthrow new Error(\n\t\t\t`[ArkEnv] Could not find schema file at ${\n\t\t\t\toptions?.schemaPath || \"src/env.ts or env.ts\"\n\t\t\t}. Please specify 'schemaPath' in withArkEnv options.`,\n\t\t);\n\t}\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\toptions?.layout,\n\t);\n\n\t// 2. Determine outputPath (defaults to generated/env.gen.ts in the same directory as schemaPath/baseDir)\n\tconst defaultOutputDir =\n\t\tresolvedLayout === \"strict\" && baseDir ? baseDir : path.dirname(schemaPath);\n\tconst defaultOutputPath = path.join(\n\t\tdefaultOutputDir,\n\t\t\"generated\",\n\t\t\"env.gen.ts\",\n\t);\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\t// 3. Run initial code generation\n\ttry {\n\t\trunCodegen(schemaPath, outputPath, resolvedLayout);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`[ArkEnv] Failed to generate env.gen.ts: ${message}`);\n\t}\n\n\t// 4. Initialize development file watcher if in dev mode\n\tconst isDev =\n\t\tprocess.env.NODE_ENV === \"development\" ||\n\t\tprocess.env.NEXT_PHASE === \"phase-development-server\";\n\tif (isDev) {\n\t\tconst watchPaths =\n\t\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t\t? [\n\t\t\t\t\t\tpath.join(baseDir, \"internal\", \"shared.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"client.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"server.ts\"),\n\t\t\t\t\t].filter(fs.existsSync)\n\t\t\t\t: [schemaPath];\n\t\twatchSchema(watchPaths, outputPath, resolvedLayout);\n\t}\n\n\treturn nextConfig;\n}\n\n/**\n * Find the path to the schema file in the project.\n *\n * @returns The absolute path to the schema file, or null if not found\n */\n/**\n * Resolve the layout (simple vs strict) and the base directory from a schema path.\n *\n * Auto-detects layout when `layoutOption` is not provided. When `layoutOption`\n * is `\"strict\"`, validates that the required split files exist and throws a\n * descriptive error if either is missing.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param layoutOption The explicit layout option, if provided\n * @returns The resolved layout and base directory\n * @throws An error if strict layout files are missing\n */\nfunction resolveLayout(\n\tschemaPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n): { layout: \"simple\" | \"strict\"; baseDir: string } {\n\tconst checkStrict = (dir: string) =>\n\t\tfs.existsSync(path.join(dir, \"internal\", \"shared.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"client.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"server.ts\"));\n\n\tconst resolveBaseDir = (p: string): string => {\n\t\t// Normalize: if schemaPath has an extension, try the extensionless form as a dir\n\t\tconst ext = path.extname(p);\n\t\tconst baseWithoutExt = ext ? p.slice(0, -ext.length) : p;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory()\n\t\t) {\n\t\t\treturn baseWithoutExt;\n\t\t}\n\t\treturn p;\n\t};\n\n\tif (!layoutOption) {\n\t\t// Auto-detect\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tif (checkStrict(resolved)) {\n\t\t\t\treturn { layout: \"strict\", baseDir: resolved };\n\t\t\t}\n\t\t\treturn { layout: \"simple\", baseDir: resolved };\n\t\t}\n\n\t\t// schemaPath is a file — check surrounding dirs\n\t\tconst parent = path.dirname(schemaPath);\n\t\tconst ext = path.extname(schemaPath);\n\t\tconst baseWithoutExt = ext ? schemaPath.slice(0, -ext.length) : schemaPath;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory() &&\n\t\t\tcheckStrict(baseWithoutExt)\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: baseWithoutExt };\n\t\t}\n\t\tif (checkStrict(parent)) {\n\t\t\treturn { layout: \"strict\", baseDir: parent };\n\t\t}\n\t\tif (\n\t\t\tpath.basename(parent) === \"internal\" &&\n\t\t\tcheckStrict(path.dirname(parent))\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: path.dirname(parent) };\n\t\t}\n\t\treturn { layout: \"simple\", baseDir: schemaPath };\n\t}\n\n\tif (layoutOption === \"strict\") {\n\t\t// Resolve baseDir for an explicit strict layout\n\t\tlet baseDir: string;\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tbaseDir = resolved;\n\t\t} else {\n\t\t\tconst parent = path.dirname(schemaPath);\n\t\t\tif (path.basename(parent) === \"internal\") {\n\t\t\t\tbaseDir = path.dirname(parent);\n\t\t\t} else {\n\t\t\t\tbaseDir = parent;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that required split files exist\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\t\tif (!fs.existsSync(clientPath) || !fs.existsSync(sharedPath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`[ArkEnv] Strict layout requires \"${clientPath}\" and \"${sharedPath}\" to exist. ` +\n\t\t\t\t\t`Ensure both files are present or remove the 'layout: \"strict\"' option to let ArkEnv auto-detect.`,\n\t\t\t);\n\t\t}\n\n\t\treturn { layout: \"strict\", baseDir };\n\t}\n\n\t// layoutOption === \"simple\"\n\treturn { layout: \"simple\", baseDir: schemaPath };\n}\n\nfunction findSchemaPath(): string | null {\n\tconst possiblePaths = [\n\t\tpath.join(process.cwd(), \"src\", \"env.ts\"),\n\t\tpath.join(process.cwd(), \"env.ts\"),\n\t];\n\tfor (const p of possiblePaths) {\n\t\tif (fs.existsSync(p)) return p;\n\t}\n\n\tconst possibleDirs = [\n\t\tpath.join(process.cwd(), \"src\", \"env\"),\n\t\tpath.join(process.cwd(), \"env\"),\n\t];\n\tfor (const d of possibleDirs) {\n\t\tif (\n\t\t\tfs.existsSync(d) &&\n\t\t\tfs.existsSync(path.join(d, \"internal\", \"shared.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"client.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"server.ts\"))\n\t\t) {\n\t\t\treturn d;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Watch the schema file for changes and trigger codegen.\n *\n * @param schemaPath The absolute path to the schema file, or an array of paths to watch\n * @param outputPath The absolute path to the generated output file\n * @param layout The resolved layout to pass through to codegen on each change\n */\nfunction watchSchema(\n\tschemaPath: string | string[],\n\toutputPath: string,\n\tlayout?: \"simple\" | \"strict\",\n) {\n\tconst previousWatcher = globalThis.__arkenv_watcher__;\n\tif (previousWatcher && typeof previousWatcher.close === \"function\") {\n\t\tpreviousWatcher.close().catch((err: unknown) => {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\tconsole.error(\n\t\t\t\t`[ArkEnv Watcher] Failed to close previous watcher: ${message}`,\n\t\t\t);\n\t\t});\n\t}\n\n\ttry {\n\t\tconst watcher = chokidarWatch(schemaPath, { ignoreInitial: true });\n\t\tglobalThis.__arkenv_watcher__ = watcher;\n\n\t\twatcher.on(\"change\", () => {\n\t\t\ttry {\n\t\t\t\tconst mainSchemaPath = Array.isArray(schemaPath)\n\t\t\t\t\t? schemaPath[0]\n\t\t\t\t\t: schemaPath;\n\t\t\t\trunCodegen(mainSchemaPath, outputPath, layout);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[ArkEnv Watcher] Failed to regenerate env.gen.ts: ${message}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t} catch (err: unknown) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\tconsole.error(\n\t\t\t`[ArkEnv Watcher] Failed to start watch on ${schemaPath}: ${message}`,\n\t\t);\n\t}\n}\n\n/**\n * Run code generation to read the schema file and generate the env.gen.ts factory.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param outputPath The absolute path to the generated output file\n * @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted\n * @throws An error if strict layout files are missing when `layoutOption` is `\"strict\"`\n */\nexport function runCodegen(\n\tschemaPath: string,\n\toutputPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n) {\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tlayoutOption,\n\t);\n\n\tlet generatedCode = \"\";\n\tif (resolvedLayout === \"strict\") {\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\n\t\tconst clientContent = fs.existsSync(clientPath)\n\t\t\t? fs.readFileSync(clientPath, \"utf-8\")\n\t\t\t: \"\";\n\t\tconst sharedContent = fs.existsSync(sharedPath)\n\t\t\t? fs.readFileSync(sharedPath, \"utf-8\")\n\t\t\t: \"\";\n\n\t\tconst clientKeys = extractClientKeys(clientContent);\n\t\tconst sharedKeys = extractSharedKeys(sharedContent);\n\n\t\tgeneratedCode = generateClientFactoryCode(clientKeys, sharedKeys);\n\t} else {\n\t\tconst fileContent = fs.readFileSync(schemaPath, \"utf-8\");\n\t\tconst { clientKeys, sharedKeys } = extractKeys(fileContent);\n\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys);\n\t}\n\n\t// Ensure parent directory exists\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\n\t// Write if changed to avoid unnecessary filesystem/watcher triggers\n\tlet shouldWrite = true;\n\tif (fs.existsSync(outputPath)) {\n\t\tconst existingContent = fs.readFileSync(outputPath, \"utf-8\");\n\t\tif (existingContent === generatedCode) {\n\t\t\tshouldWrite = false;\n\t\t}\n\t}\n\n\tif (shouldWrite) {\n\t\tfs.writeFileSync(outputPath, generatedCode, \"utf-8\");\n\t}\n}\n\n/**\n * Statically extract client and shared keys from the schema content.\n *\n * @param content The schema file string content\n * @returns An object containing the extracted client and shared keys\n */\nexport function extractKeys(content: string): {\n\tclientKeys: string[];\n\tsharedKeys: string[];\n} {\n\tconst clientKeys: string[] = [];\n\tconst sharedKeys: string[] = [];\n\n\t// Extract client block\n\tconst clientBlock = extractBlock(content, \"client\");\n\tif (clientBlock) {\n\t\tclientKeys.push(...parseBlockKeys(clientBlock));\n\t}\n\n\t// Extract shared block\n\tconst sharedBlock = extractBlock(content, \"shared\");\n\tif (sharedBlock) {\n\t\tsharedKeys.push(...parseBlockKeys(sharedBlock));\n\t}\n\n\treturn { clientKeys, sharedKeys };\n}\n\n/**\n * Extract a specific block from the schema content by name.\n *\n * @param content The schema file string content\n * @param blockName The name of the block to extract (e.g., 'client' or 'shared')\n * @returns The contents of the block, or null if not found\n */\nfunction extractBlock(content: string, blockName: string): string | null {\n\t// Find \"\\bblockName\\s*:\\s*{\" or \"\\bblockName\\s*:\\s*type({\"\n\tconst regex = new RegExp(\n\t\t`\\\\b${blockName}\\\\s*:\\\\s*(?:[a-zA-Z0-9_$.]+\\\\s*\\\\(\\\\s*)?\\\\{`,\n\t\t\"g\",\n\t);\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Parse environment variable keys from a block's content.\n *\n * @param blockContent The raw content of the block\n * @returns An array of parsed environment variable keys\n */\nfunction parseBlockKeys(blockContent: string): string[] {\n\tconst keys: string[] = [];\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\tlet currentToken = \"\";\n\tlet lastStringContent = \"\";\n\tlet braceDepth = 0;\n\n\tfor (let i = 0; i < blockContent.length; i++) {\n\t\tconst char = blockContent[i];\n\t\tconst nextChar = blockContent[i + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && blockContent[i - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t\tlastStringContent = currentToken;\n\t\t\t\tcurrentToken = \"\";\n\t\t\t} else {\n\t\t\t\tcurrentToken += char;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Start comments/strings\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tcurrentToken = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceDepth++;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"}\") {\n\t\t\tbraceDepth--;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \":\") {\n\t\t\tif (braceDepth === 0) {\n\t\t\t\tconst key = currentToken.trim() || lastStringContent.trim();\n\t\t\t\tif (key) {\n\t\t\t\t\tkeys.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (/[a-zA-Z0-9_$]/.test(char)) {\n\t\t\tcurrentToken += char;\n\t\t} else if (char === \",\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t}\n\t}\n\n\treturn keys;\n}\n\n/**\n * Generate the TypeScript factory code for the tailored arkenv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @returns The generated TypeScript source code string\n */\nfunction generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { arkenv as coreArkenv } from \"@arkenv/nextjs\";\nimport type { Infer } from \"@arkenv/nextjs\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function arkenv<\n\tconst TServer extends Record<string, any> = {},\n\tconst TClient extends Record<string, any> = {},\n\tconst TShared extends Record<string, any> = {},\n>(options: {\n\tserver?: TServer;\n\tclient?: TClient & {\n\t\t[K in keyof TClient]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t};\n\tshared?: TShared;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\treturn coreArkenv({\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any) as any;\n}\n\nexport default arkenv;\n`;\n}\n\n/**\n * Generate the TypeScript factory code for the strict-layout `arkenv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @returns The generated TypeScript source code string\n */\nfunction generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { arkenv as coreArkenv } from \"@arkenv/nextjs/client\";\n\nexport { type } from \"@arkenv/nextjs/client\";\n\nexport function arkenv<\n\tconst TSchema extends Record<string, any> = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema & {\n\t\t[K in keyof TSchema]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t},\n\toptions?: {\n\t\textends?: [...TExtends];\n\t},\n) {\n\treturn coreArkenv<TSchema, TExtends>(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);\n}\n\nexport default arkenv;\n`;\n}\n\n/**\n * Extract env var keys from a strict-layout `client.ts` file.\n *\n * Locates the first `arkenv({...})` call and delegates to `parseBlockKeys`\n * to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `client.ts`\n * @returns An array of env var key names found in the client schema\n */\nexport function extractClientKeys(content: string): string[] {\n\tconst block = extractClientBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract env var keys from a strict-layout `internal/shared.ts` file.\n *\n * Locates the `SharedSchema = ...({...})` assignment and delegates to\n * `parseBlockKeys` to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns An array of env var key names found in the shared schema\n */\nexport function extractSharedKeys(content: string): string[] {\n\tconst block = extractSharedBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract the schema object body from a strict-layout `client.ts` file.\n *\n * Matches the first `arkenv(...)` call, then performs brace-balanced\n * traversal while respecting strings and comments to find the boundaries\n * of the first argument object.\n *\n * @param content The source text of `client.ts`\n * @returns The raw text inside the first `{...}` argument, or `null` if not found\n */\nfunction extractClientBlock(content: string): string | null {\n\tconst regex = /\\barkenv\\s*\\(\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract the schema object body from a strict-layout `internal/shared.ts` file.\n *\n * Matches the `SharedSchema = ...({...})` assignment, then performs\n * brace-balanced traversal while respecting strings and comments to find\n * the boundaries of the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns The raw text inside the `{...}` schema object, or `null` if not found\n */\nfunction extractSharedBlock(content: string): string | null {\n\tconst regex = /\\bSharedSchema\\s*=\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n"],"mappings":"iFAsEA,SAAgB,EAAc,EAAe,EAAkC,CAE9E,IAAM,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,GAAgB,CAGf,EAAS,GACb,GAAI,EACH,GAAI,EAAG,WAAW,EAAW,CAC5B,EAAS,OACH,CACN,IAAM,EAAM,EAAK,QAAQ,EAAW,CACpC,GAAI,EAAK,CACR,IAAM,EAAiB,EAAW,MAAM,EAAG,CAAC,EAAI,OAAO,CACnD,EAAG,WAAW,EAAe,GAChC,EAAS,KAMb,GAAI,CAAC,GAAc,CAAC,EACnB,MAAU,MACT,0CACC,GAAS,YAAc,uBACvB,sDACD,CAGF,GAAM,CAAE,OAAQ,EAAgB,WAAY,EAC3C,EACA,GAAS,OACT,CAGK,EACL,IAAmB,UAAY,EAAU,EAAU,EAAK,QAAQ,EAAW,CACtE,EAAoB,EAAK,KAC9B,EACA,YACA,aACA,CACK,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,EAGH,GAAI,CACH,EAAW,E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,SAED,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,QACZ,GAAS,EACT,SAED,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,CACjD,EAAW,EACX,IACA,SAGG,IAAS,IACZ,IACU,IAAS,KACnB,IAED,IAOD,OAJI,IAAe,EACX,EAAQ,MAAM,EAAY,EAAQ,EAAE,CAGrC,KAaR,SAAS,EAAmB,EAAgC,CAC3D,IAAM,EAAQ,uDAEd,GAAI,CADU,EAAM,KAAK,EACf,CAAE,OAAO,KAEnB,IAAM,EAAa,EAAM,UACrB,EAAa,EACb,EAAQ,EACR,EAA0B,KAC1B,EAAuC,KAE3C,KAAO,EAAQ,EAAQ,QAAU,EAAa,GAAG,CAChD,IAAM,EAAO,EAAQ,GACf,EAAW,EAAQ,EAAQ,GAEjC,GAAI,IAAc,SAAU,EACvB,IAAS;GAAQ,IAAS,QAAM,EAAY,MAChD,IACA,SAED,GAAI,IAAc,QAAS,CAC1B,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,KACZ,GAAS,EACT,SAED,IACA,SAGD,GAAI,EAAU,CACT,IAAS,GAAY,EAAQ,EAAQ,KAAO,OAC/C,EAAW,MAEZ,IACA,SAGD,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,SACZ,GAAS,EACT,SAED,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,QACZ,GAAS,EACT,SAED,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,CACjD,EAAW,EACX,IACA,SAGG,IAAS,IACZ,IACU,IAAS,KACnB,IAED,IAOD,OAJI,IAAe,EACX,EAAQ,MAAM,EAAY,EAAQ,EAAE,CAGrC"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-DDWVuzwL.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t){return e.t(t,!1)}const r=n;exports.createEnv=n,exports.default=r,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./arkenv-internal-DA4LpI3t.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t){return e.t(t,!1)}exports.arkenv=n,exports.default=n,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/index.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { createEnvInternal } from \"./create-env\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn createEnvInternal(options, false) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"4LAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAOA,EAAAA,EAAkB,EAAS,GAAM,CAWzC,MAAMC,EAAS"}
1
+ {"version":3,"file":"index.cjs","names":["arkenv","arkenvInternal"],"sources":["../src/index.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { arkenvInternal } from \"./arkenv-internal\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn arkenvInternal(options, false) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"iMAYA,SAAgBA,EAId,EAQ+C,CAEhD,OAAOC,EAAAA,EAAe,EAAS,GAAM"}
package/dist/index.d.cts CHANGED
@@ -10,18 +10,12 @@ import { EnvSchema, Infer, Infer as Infer$1, type } from "arkenv";
10
10
  * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`
11
11
  * @throws An error if any client or shared variable is missing from `runtimeEnv`
12
12
  */
13
- declare function createEnv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
13
+ declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
14
14
  server?: EnvSchema<TServer>;
15
15
  client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
16
16
  shared?: EnvSchema<TShared>;
17
17
  runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
18
18
  }): Readonly<Infer$1<TServer & TClient & TShared>>;
19
- /**
20
- * ArkEnv's Next.js integration export, an alias for {@link createEnv}
21
- *
22
- * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
23
- */
24
- declare const arkenv: typeof createEnv;
25
19
  //#endregion
26
- export { type Infer, createEnv, arkenv as default, type };
20
+ export { type Infer, arkenv, arkenv as default, type };
27
21
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,SAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA;;;;;;cAajC,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,MAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
package/dist/index.d.ts CHANGED
@@ -10,18 +10,12 @@ import { EnvSchema, Infer, Infer as Infer$1, type } from "arkenv";
10
10
  * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`
11
11
  * @throws An error if any client or shared variable is missing from `runtimeEnv`
12
12
  */
13
- declare function createEnv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
13
+ declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
14
14
  server?: EnvSchema<TServer>;
15
15
  client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
16
16
  shared?: EnvSchema<TShared>;
17
17
  runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
18
18
  }): Readonly<Infer$1<TServer & TClient & TShared>>;
19
- /**
20
- * ArkEnv's Next.js integration export, an alias for {@link createEnv}
21
- *
22
- * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
23
- */
24
- declare const arkenv: typeof createEnv;
25
19
  //#endregion
26
- export { type Infer, createEnv, arkenv as default, type };
20
+ export { type Infer, arkenv, arkenv as default, type };
27
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,SAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA;;;;;;cAajC,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,MAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./create-env-BfXQtLQM.js";import{type as t}from"arkenv";function n(t){return e(t,!1)}const r=n;export{n as createEnv,r as default,t as type};
1
+ import{t as e}from"./arkenv-internal-cagrxXTM.js";import{type as t}from"arkenv";function n(t){return e(t,!1)}export{n as arkenv,n as default,t as type};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { createEnvInternal } from \"./create-env\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn createEnvInternal(options, false) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"2EAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAO,EAAkB,EAAS,GAAM,CAWzC,MAAM,EAAS"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { arkenvInternal } from \"./arkenv-internal\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn arkenvInternal(options, false) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"gFAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAO,EAAe,EAAS,GAAM"}
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-DDWVuzwL.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t){return e.t(t,!0)}const r=n;exports.createEnv=n,exports.default=r,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./arkenv-internal-DA4LpI3t.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t){return e.t(t,!0)}exports.arkenv=n,exports.default=n,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
2
2
  //# sourceMappingURL=react-server.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-server.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/react-server.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { createEnvInternal } from \"./create-env\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server-side RSC entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn createEnvInternal(options, true) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"4LAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAOA,EAAAA,EAAkB,EAAS,GAAK,CAWxC,MAAMC,EAAS"}
1
+ {"version":3,"file":"react-server.cjs","names":["arkenv","arkenvInternal"],"sources":["../src/react-server.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { arkenvInternal } from \"./arkenv-internal\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server-side RSC entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn arkenvInternal(options, true) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"iMAYA,SAAgBA,EAId,EAQ+C,CAEhD,OAAOC,EAAAA,EAAe,EAAS,GAAK"}
@@ -10,18 +10,12 @@ import { EnvSchema, Infer, Infer as Infer$1, type } from "arkenv";
10
10
  * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`
11
11
  * @throws An error if any client or shared variable is missing from `runtimeEnv`
12
12
  */
13
- declare function createEnv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
13
+ declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
14
14
  server?: EnvSchema<TServer>;
15
15
  client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
16
16
  shared?: EnvSchema<TShared>;
17
17
  runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
18
18
  }): Readonly<Infer$1<TServer & TClient & TShared>>;
19
- /**
20
- * ArkEnv's Next.js integration export, an alias for {@link createEnv}
21
- *
22
- * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
23
- */
24
- declare const arkenv: typeof createEnv;
25
19
  //#endregion
26
- export { type Infer, createEnv, arkenv as default, type };
20
+ export { type Infer, arkenv, arkenv as default, type };
27
21
  //# sourceMappingURL=react-server.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-server.d.cts","names":[],"sources":["../src/react-server.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,SAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA;;;;;;cAajC,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"react-server.d.cts","names":[],"sources":["../src/react-server.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,MAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
@@ -10,18 +10,12 @@ import { EnvSchema, Infer, Infer as Infer$1, type } from "arkenv";
10
10
  * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`
11
11
  * @throws An error if any client or shared variable is missing from `runtimeEnv`
12
12
  */
13
- declare function createEnv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
13
+ declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
14
14
  server?: EnvSchema<TServer>;
15
15
  client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
16
16
  shared?: EnvSchema<TShared>;
17
17
  runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
18
18
  }): Readonly<Infer$1<TServer & TClient & TShared>>;
19
- /**
20
- * ArkEnv's Next.js integration export, an alias for {@link createEnv}
21
- *
22
- * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.
23
- */
24
- declare const arkenv: typeof createEnv;
25
19
  //#endregion
26
- export { type Infer, createEnv, arkenv as default, type };
20
+ export { type Infer, arkenv, arkenv as default, type };
27
21
  //# sourceMappingURL=react-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-server.d.ts","names":[],"sources":["../src/react-server.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,SAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA;;;;;;cAajC,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"react-server.d.ts","names":[],"sources":["../src/react-server.ts"],"mappings":";;;;;;AAYA;;;;;;iBAAgB,MAAA,uBACO,WAAA,6BACA,WAAA,6BACA,WAAA,MAAA,CACrB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CAAS,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
@@ -1,2 +1,2 @@
1
- import{t as e}from"./create-env-BfXQtLQM.js";import{type as t}from"arkenv";function n(t){return e(t,!0)}const r=n;export{n as createEnv,r as default,t as type};
1
+ import{t as e}from"./arkenv-internal-cagrxXTM.js";import{type as t}from"arkenv";function n(t){return e(t,!0)}export{n as arkenv,n as default,t as type};
2
2
  //# sourceMappingURL=react-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-server.js","names":[],"sources":["../src/react-server.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { createEnvInternal } from \"./create-env\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server-side RSC entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn createEnvInternal(options, true) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export, an alias for {@link createEnv}\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"2EAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAO,EAAkB,EAAS,GAAK,CAWxC,MAAM,EAAS"}
1
+ {"version":3,"file":"react-server.js","names":[],"sources":["../src/react-server.ts"],"sourcesContent":["import type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema, Infer } from \"arkenv\";\nimport { arkenvInternal } from \"./arkenv-internal\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server-side RSC entry point).\n *\n * @param options The environment validation configuration options\n * @returns A validated, readonly environment variables object wrapped in a security proxy\n * @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`\n * @throws An error if any client or shared variable is missing from `runtimeEnv`\n */\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tclient?: EnvSchema<TClient> & {\n\t\t[K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never;\n\t};\n\tshared?: EnvSchema<TShared>;\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\ttype ReturnType = Readonly<Infer<TServer & TClient & TShared>>;\n\treturn arkenvInternal(options, true) as ReturnType;\n}\n\nexport type { Infer } from \"arkenv\";\nexport { type } from \"arkenv\";\n\n/**\n * ArkEnv's Next.js integration export\n *\n * {@link https://arkenv.js.org | ArkEnv} is a typesafe environment variables validator from editor to runtime.\n */\nexport default arkenv;\n"],"mappings":"gFAYA,SAAgB,EAId,EAQ+C,CAEhD,OAAO,EAAe,EAAS,GAAK"}
package/dist/server.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-DDWVuzwL.cjs`);require(`./config.cjs`);let t=require(`arkenv`);require(`server-only`);function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`server`in t||`shared`in t)){if(`client`in t)throw Error(`server entry point only accepts 'server' and 'shared' schemas.`);return e.t(t,!0)}return e.t(t,n,{isServer:!0})}const r=n;exports.createEnv=n,exports.default=r,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./arkenv-internal-DA4LpI3t.cjs`);require(`./config.cjs`);let t=require(`arkenv`);require(`server-only`);function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`server`in t||`shared`in t)){if(`client`in t)throw Error(`server entry point only accepts 'server' and 'shared' schemas.`);return e.t(t,!0)}return e.t(t,n,{isServer:!0})}exports.arkenv=n,exports.default=n,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
2
2
  //# sourceMappingURL=server.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/server.ts"],"sourcesContent":["import \"server-only\";\nimport type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tshared?: EnvSchema<TShared>;\n\textends?: [...TExtends];\n\truntimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TServer & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"server\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"client\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"server entry point only accepts 'server' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, true);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: true,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"mNAmCA,SAAgB,EAAU,EAAsB,EAA8B,CAQ7E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAOA,EAAAA,EAAkB,EAAiB,GAAK,CAGhD,OAAOA,EAAAA,EAAkB,EAAiB,EAAmB,CAC5D,SAAU,GACV,CAAC,CAKH,MAAMC,EAAS"}
1
+ {"version":3,"file":"server.cjs","names":["arkenv","arkenvInternal"],"sources":["../src/server.ts"],"sourcesContent":["import \"server-only\";\nimport type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { arkenvInternal } from \"./arkenv-internal\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).\n */\nexport function arkenv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tshared?: EnvSchema<TShared>;\n\textends?: [...TExtends];\n\truntimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TServer & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function arkenv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"server\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"client\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"server entry point only accepts 'server' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn arkenvInternal(schemaOrOptions, true);\n\t}\n\n\treturn arkenvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: true,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nexport default arkenv;\n"],"mappings":"wNAmCA,SAAgBA,EAAO,EAAsB,EAA8B,CAQ1E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAOC,EAAAA,EAAe,EAAiB,GAAK,CAG7C,OAAOA,EAAAA,EAAe,EAAiB,EAAmB,CACzD,SAAU,GACV,CAAC"}
package/dist/server.d.cts CHANGED
@@ -6,17 +6,16 @@ import { EnvSchema, type } from "arkenv";
6
6
  /**
7
7
  * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).
8
8
  */
9
- declare function createEnv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
9
+ declare function arkenv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
10
10
  extends?: [...TExtends];
11
11
  runtimeEnv?: Record<keyof TSchema | string, unknown>;
12
12
  }): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
13
- declare function createEnv<const TServer extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
13
+ declare function arkenv<const TServer extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
14
14
  server?: EnvSchema<TServer>;
15
15
  shared?: EnvSchema<TShared>;
16
16
  extends?: [...TExtends];
17
17
  runtimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;
18
18
  }): Readonly<distill.Out<type$1.infer<TServer & TShared, $>> & MergeExtends<TExtends>>;
19
- declare const arkenv: typeof createEnv;
20
19
  //#endregion
21
- export { createEnv, arkenv as default, type };
20
+ export { arkenv, arkenv as default, type };
22
21
  //# sourceMappingURL=server.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.cts","names":[],"sources":["../src/server.ts"],"mappings":";;;;;;AAWA;;iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,iBAE7C,SAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA,aAAoB,MAAA;AAAA,IAC3C,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cA2BtD,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"server.d.cts","names":[],"sources":["../src/server.ts"],"mappings":";;;;;;AAWA;;iBAAgB,MAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,iBAE7C,MAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA,aAAoB,MAAA;AAAA,IAC3C,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA"}
package/dist/server.d.ts CHANGED
@@ -7,17 +7,16 @@ import { distill, type as type$1 } from "arktype";
7
7
  /**
8
8
  * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).
9
9
  */
10
- declare function createEnv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
10
+ declare function arkenv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
11
11
  extends?: [...TExtends];
12
12
  runtimeEnv?: Record<keyof TSchema | string, unknown>;
13
13
  }): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
14
- declare function createEnv<const TServer extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
14
+ declare function arkenv<const TServer extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
15
15
  server?: EnvSchema<TServer>;
16
16
  shared?: EnvSchema<TShared>;
17
17
  extends?: [...TExtends];
18
18
  runtimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;
19
19
  }): Readonly<distill.Out<type$1.infer<TServer & TShared, $>> & MergeExtends<TExtends>>;
20
- declare const arkenv: typeof createEnv;
21
20
  //#endregion
22
- export { createEnv, arkenv as default, type };
21
+ export { arkenv, arkenv as default, type };
23
22
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":";;;;;;;AAWA;;iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,iBAE7C,SAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA,aAAoB,MAAA;AAAA,IAC3C,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cA2BtD,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"server.d.ts","names":[],"sources":["../src/server.ts"],"mappings":";;;;;;;AAWA;;iBAAgB,MAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,iBAE7C,MAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA,aAAoB,MAAA;AAAA,IAC3C,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA"}
package/dist/server.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./create-env-BfXQtLQM.js";import{type as t}from"arkenv";import"server-only";function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`server`in t||`shared`in t)){if(`client`in t)throw Error(`server entry point only accepts 'server' and 'shared' schemas.`);return e(t,!0)}return e(t,n,{isServer:!0})}const r=n;export{n as createEnv,r as default,t as type};
1
+ import{t as e}from"./arkenv-internal-cagrxXTM.js";import{type as t}from"arkenv";import"server-only";function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`server`in t||`shared`in t)){if(`client`in t)throw Error(`server entry point only accepts 'server' and 'shared' schemas.`);return e(t,!0)}return e(t,n,{isServer:!0})}export{n as arkenv,n as default,t as type};
2
2
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import \"server-only\";\nimport type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function createEnv<\n\tconst TServer extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tshared?: EnvSchema<TShared>;\n\textends?: [...TExtends];\n\truntimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TServer & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"server\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"client\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"server entry point only accepts 'server' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, true);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: true,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"+FAmCA,SAAgB,EAAU,EAAsB,EAA8B,CAQ7E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAO,EAAkB,EAAiB,GAAK,CAGhD,OAAO,EAAkB,EAAiB,EAAmB,CAC5D,SAAU,GACV,CAAC,CAKH,MAAM,EAAS"}
1
+ {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import \"server-only\";\nimport type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { arkenvInternal } from \"./arkenv-internal\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Server entry point).\n */\nexport function arkenv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function arkenv<\n\tconst TServer extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\n\tserver?: EnvSchema<TServer>;\n\tshared?: EnvSchema<TShared>;\n\textends?: [...TExtends];\n\truntimeEnv?: Record<keyof TShared, unknown> & Record<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TServer & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function arkenv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"server\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"client\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"server entry point only accepts 'server' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn arkenvInternal(schemaOrOptions, true);\n\t}\n\n\treturn arkenvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: true,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nexport default arkenv;\n"],"mappings":"oGAmCA,SAAgB,EAAO,EAAsB,EAA8B,CAQ1E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAO,EAAe,EAAiB,GAAK,CAG7C,OAAO,EAAe,EAAiB,EAAmB,CACzD,SAAU,GACV,CAAC"}
package/dist/shared.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-DDWVuzwL.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t,n){return e.t(t,n,{isServer:typeof window>`u`,isShared:!0})}const r=n;exports.createEnv=n,exports.default=r,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./arkenv-internal-DA4LpI3t.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t,n){return e.t(t,n,{isServer:typeof window>`u`,isShared:!0})}exports.arkenv=n,exports.default=n,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
2
2
  //# sourceMappingURL=shared.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/shared.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>> {\n\tconst isServer = typeof window === \"undefined\";\n\treturn createEnvInternal(schema, options, {\n\t\tisServer,\n\t\tisShared: true,\n\t}) as any;\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"4LAUA,SAAgB,EAIf,EACA,EAIuE,CAEvE,OAAOA,EAAAA,EAAkB,EAAQ,EAAS,CACzC,SAFgB,OAAO,OAAW,IAGlC,SAAU,GACV,CAAC,CAKH,MAAMC,EAAS"}
1
+ {"version":3,"file":"shared.cjs","names":["arkenv","arkenvInternal"],"sources":["../src/shared.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { arkenvInternal } from \"./arkenv-internal\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).\n */\nexport function arkenv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>> {\n\tconst isServer = typeof window === \"undefined\";\n\treturn arkenvInternal(schema, options, {\n\t\tisServer,\n\t\tisShared: true,\n\t}) as any;\n}\n\nexport { type } from \"arkenv\";\n\nexport default arkenv;\n"],"mappings":"iMAUA,SAAgBA,EAIf,EACA,EAIuE,CAEvE,OAAOC,EAAAA,EAAe,EAAQ,EAAS,CACtC,SAFgB,OAAO,OAAW,IAGlC,SAAU,GACV,CAAC"}
package/dist/shared.d.cts CHANGED
@@ -7,11 +7,10 @@ import { EnvSchema, type } from "arkenv";
7
7
  /**
8
8
  * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).
9
9
  */
10
- declare function createEnv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
10
+ declare function arkenv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
11
11
  extends?: [...TExtends];
12
12
  runtimeEnv?: Record<keyof TSchema | string, unknown>;
13
13
  }): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
14
- declare const arkenv: typeof createEnv;
15
14
  //#endregion
16
- export { createEnv, arkenv as default, type };
15
+ export { arkenv, arkenv as default, type };
17
16
  //# sourceMappingURL=shared.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.cts","names":[],"sources":["../src/shared.ts"],"mappings":";;;;;;;AAUA;;iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cAUvD,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"shared.d.cts","names":[],"sources":["../src/shared.ts"],"mappings":";;;;;;;AAUA;;iBAAgB,MAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA"}
package/dist/shared.d.ts CHANGED
@@ -7,11 +7,10 @@ import { distill, type as type$1 } from "arktype";
7
7
  /**
8
8
  * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).
9
9
  */
10
- declare function createEnv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
10
+ declare function arkenv<const TSchema extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
11
11
  extends?: [...TExtends];
12
12
  runtimeEnv?: Record<keyof TSchema | string, unknown>;
13
13
  }): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
14
- declare const arkenv: typeof createEnv;
15
14
  //#endregion
16
- export { createEnv, arkenv as default, type };
15
+ export { arkenv, arkenv as default, type };
17
16
  //# sourceMappingURL=shared.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","names":[],"sources":["../src/shared.ts"],"mappings":";;;;;;;AAUA;;iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cAUvD,MAAA,SAAM,SAAA"}
1
+ {"version":3,"file":"shared.d.ts","names":[],"sources":["../src/shared.ts"],"mappings":";;;;;;;AAUA;;iBAAgB,MAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA,OAAa,OAAA;AAAA,IAEzB,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA"}
package/dist/shared.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as e}from"./create-env-BfXQtLQM.js";import{type as t}from"arkenv";function n(t,n){return e(t,n,{isServer:typeof window>`u`,isShared:!0})}const r=n;export{n as createEnv,r as default,t as type};
1
+ import{t as e}from"./arkenv-internal-cagrxXTM.js";import{type as t}from"arkenv";function n(t,n){return e(t,n,{isServer:typeof window>`u`,isShared:!0})}export{n as arkenv,n as default,t as type};
2
2
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>> {\n\tconst isServer = typeof window === \"undefined\";\n\treturn createEnvInternal(schema, options, {\n\t\tisServer,\n\t\tisShared: true,\n\t}) as any;\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"2EAUA,SAAgB,EAIf,EACA,EAIuE,CAEvE,OAAO,EAAkB,EAAQ,EAAS,CACzC,SAFgB,OAAO,OAAW,IAGlC,SAAU,GACV,CAAC,CAKH,MAAM,EAAS"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { arkenvInternal } from \"./arkenv-internal\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Shared entry point).\n */\nexport function arkenv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<TSchema>,\n\toptions?: {\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<keyof TSchema | string, unknown>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>> {\n\tconst isServer = typeof window === \"undefined\";\n\treturn arkenvInternal(schema, options, {\n\t\tisServer,\n\t\tisShared: true,\n\t}) as any;\n}\n\nexport { type } from \"arkenv\";\n\nexport default arkenv;\n"],"mappings":"gFAUA,SAAgB,EAIf,EACA,EAIuE,CAEvE,OAAO,EAAe,EAAQ,EAAS,CACtC,SAFgB,OAAO,OAAW,IAGlC,SAAU,GACV,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkenv/nextjs",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "author": "Yam Borodetsky <yam@yam.codes>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "chokidar": "^4.0.3",
13
13
  "server-only": "^0.0.1",
14
- "arkenv": "1.0.0-alpha.0"
14
+ "arkenv": "1.0.0-alpha.1"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@size-limit/preset-small-lib": "12.1.0",
@@ -1,2 +0,0 @@
1
- import{createEnv as e}from"arkenv";const t=Symbol.for(`arkenv.extended_env`),n=Symbol.for(`arkenv.keys`),r=Symbol.for(`arkenv.server_only_keys`);function i(e){if(!e||typeof e!=`object`&&typeof e!=`function`)return[];if(e.json&&typeof e.json==`object`&&e.json.domain===`object`){let t=[];if(Array.isArray(e.json.required))for(let n of e.json.required)n&&typeof n==`object`&&`key`in n&&t.push(n.key);if(Array.isArray(e.json.optional))for(let n of e.json.optional)n&&typeof n==`object`&&`key`in n&&t.push(n.key);return t}return`shape`in e&&e.shape&&typeof e.shape==`object`?Object.keys(e.shape):`entries`in e&&e.entries&&typeof e.entries==`object`?Object.keys(e.entries):Object.keys(e)}function a(a,o,s){let c={},l={},u={},d=[],f={},p=!1;if(typeof o==`boolean`)c=a.server||{},l=a.client||{},u=a.shared||{},d=a.extends||[],f=a.runtimeEnv||{},p=o;else{let e=a||{},t=o||{};d=t.extends||[],f=t.runtimeEnv||{},p=!!s?.isServer,s?.isShared?u=e:p?c=e:l=e}let m={},h=new Set,g=new Set;for(let e of Object.keys(c))h.add(e),!(e in l)&&!(e in u)&&g.add(e);for(let e of Object.keys(l))h.add(e);for(let e of Object.keys(u))h.add(e);let _={};if(d&&Array.isArray(d)){for(let a of d)if(a&&(typeof a==`object`||typeof a==`function`)){let o=a[t];if(o){m={...m,...o};let e=a[n];if(e instanceof Set)for(let t of e)h.add(t);let t=a[r];if(t instanceof Set)for(let e of t)g.add(e)}else{for(let e of Object.keys(m))m[e]!==void 0&&(_[e]=String(m[e]));for(let e of Object.keys(f))f[e]!==void 0&&(_[e]=f[e]);if(p)for(let e of Object.keys(c))_[e]===void 0&&process.env[e]!==void 0&&(_[e]=process.env[e]);let t=e(a,{env:_});m={...m,...t};let n=i(a);for(let e of n)h.add(e),p&&!e.startsWith(`NEXT_PUBLIC_`)&&!s?.isShared&&g.add(e)}}}for(let e of Object.keys(l))g.delete(e);for(let e of Object.keys(u))g.delete(e);for(let e of Object.keys(l))if(!e.startsWith(`NEXT_PUBLIC_`))throw Error(`Client-side environment variables must be prefixed with 'NEXT_PUBLIC_'. Found invalid key: ${e}`);let v=[...Object.keys(l),...Object.keys(u)];for(let e of v)if(!(e in f))throw Error(`Missing key in runtimeEnv: ${e}. All client and shared environment variables must be explicitly destructured in runtimeEnv.`);for(let e of Object.keys(f))if(!h.has(e))throw Error(`Environment variable '${e}' is passed to runtimeEnv but is not defined in the schema.`);for(let e of Object.keys(m))m[e]!==void 0&&(_[e]=String(m[e]));for(let e of Object.keys(f))f[e]!==void 0&&(_[e]=f[e]);if(p)for(let e of Object.keys(c))_[e]===void 0&&process.env[e]!==void 0&&(_[e]=process.env[e]);let y=e(p?{...c,...l,...u}:{...l,...u},{env:_}),b={...m,...y};return new Proxy(b,{get(e,i,a){if(i===t)return e;if(i===n)return h;if(i===r)return g;if(typeof i==`symbol`)return Reflect.get(e,i,a);if(typeof i==`string`){if(g.has(i)&&!p)throw Error(`Accessing server-side environment variable '${i}' on the client is not allowed.`);if(!h.has(i)&&!(i in Object.prototype)&&!(i===`__esModule`||i===`$$typeof`||i===`toJSON`||i===`inspect`))throw Error(`Environment variable '${i}' is not defined in the schema.`)}return Reflect.get(e,i,a)}})}export{a as t};
2
- //# sourceMappingURL=create-env-BfXQtLQM.js.map