@arkenv/nextjs 1.0.0-alpha.10 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/arkenv-internal-QxkUlA5J.cjs +2 -0
- package/dist/arkenv-internal-QxkUlA5J.cjs.map +1 -0
- package/dist/arkenv-internal-Ws3srax6.js +2 -0
- package/dist/arkenv-internal-Ws3srax6.js.map +1 -0
- package/dist/auto-extend-CYzZnEvT.cjs +2 -0
- package/dist/auto-extend-CYzZnEvT.cjs.map +1 -0
- package/dist/auto-extend-DjiqIbgM.js +2 -0
- package/dist/auto-extend-DjiqIbgM.js.map +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/config/index.cjs +1 -1
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config-Deut5Vf8.js +99 -0
- package/dist/config-Deut5Vf8.js.map +1 -0
- package/dist/config-Oq8dsEPM.cjs +99 -0
- package/dist/config-Oq8dsEPM.cjs.map +1 -0
- package/dist/empty-client-env.cjs +2 -0
- package/dist/empty-client-env.cjs.map +1 -0
- package/dist/empty-client-env.d.cts +10 -0
- package/dist/empty-client-env.d.cts.map +1 -0
- package/dist/empty-client-env.d.ts +10 -0
- package/dist/empty-client-env.d.ts.map +1 -0
- package/dist/empty-client-env.js +2 -0
- package/dist/empty-client-env.js.map +1 -0
- package/dist/{index-96RGPyfa.d.cts → index-BS1wAitS.d.cts} +91 -31
- package/dist/{index-96RGPyfa.d.cts.map → index-BS1wAitS.d.cts.map} +1 -1
- package/dist/{index-BFQlm61W.d.ts → index-CBjJM83X.d.ts} +54 -14
- package/dist/index-CBjJM83X.d.ts.map +1 -0
- package/dist/{index-bjEZwPUt.d.ts → index-Cq_qJ68V.d.ts} +91 -31
- package/dist/{index-bjEZwPUt.d.ts.map → index-Cq_qJ68V.d.ts.map} +1 -1
- package/dist/{index-CNzwVE5N.d.cts → index-RdYGBD_V.d.cts} +54 -14
- package/dist/index-RdYGBD_V.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-server.cjs +1 -1
- package/dist/react-server.cjs.map +1 -1
- package/dist/react-server.d.cts +11 -5
- package/dist/react-server.d.cts.map +1 -1
- package/dist/react-server.d.ts +12 -6
- package/dist/react-server.d.ts.map +1 -1
- package/dist/react-server.js +1 -1
- package/dist/react-server.js.map +1 -1
- package/dist/{script-7FFqInPq.d.ts → script-Cy9x6rp9.d.ts} +1 -1
- package/dist/{script-7FFqInPq.d.ts.map → script-Cy9x6rp9.d.ts.map} +1 -1
- package/dist/{script-D-MYC2Uf.cjs → script-DAdH4IEa.cjs} +2 -2
- package/dist/{script-D-MYC2Uf.cjs.map → script-DAdH4IEa.cjs.map} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +24 -5
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +24 -5
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/standard/client.cjs +1 -1
- package/dist/standard/client.cjs.map +1 -1
- package/dist/standard/client.d.cts +3 -3
- package/dist/standard/client.d.ts +3 -3
- package/dist/standard/client.js +1 -1
- package/dist/standard/client.js.map +1 -1
- package/dist/standard/config.cjs +1 -1
- package/dist/standard/config.cjs.map +1 -1
- package/dist/standard/config.d.cts +6 -5
- package/dist/standard/config.d.cts.map +1 -1
- package/dist/standard/config.d.ts +6 -5
- package/dist/standard/config.d.ts.map +1 -1
- package/dist/standard/config.js +1 -1
- package/dist/standard/config.js.map +1 -1
- package/dist/standard/index.cjs +1 -1
- package/dist/standard/index.cjs.map +1 -1
- package/dist/standard/index.d.cts +4 -4
- package/dist/standard/index.d.ts +4 -4
- package/dist/standard/index.js +1 -1
- package/dist/standard/index.js.map +1 -1
- package/dist/standard/server.cjs +1 -1
- package/dist/standard/server.cjs.map +1 -1
- package/dist/standard/server.d.cts +27 -7
- package/dist/standard/server.d.cts.map +1 -1
- package/dist/standard/server.d.ts +28 -7
- package/dist/standard/server.d.ts.map +1 -1
- package/dist/standard/server.js +1 -1
- package/dist/standard/server.js.map +1 -1
- package/dist/standard/shared.cjs +1 -1
- package/dist/standard/shared.cjs.map +1 -1
- package/dist/standard/shared.d.cts +2 -2
- package/dist/standard/shared.d.ts +2 -2
- package/dist/standard/shared.js +1 -1
- package/dist/standard/shared.js.map +1 -1
- package/dist/strict-client-env-CHDTZoLe.js +6 -0
- package/dist/strict-client-env-CHDTZoLe.js.map +1 -0
- package/dist/strict-client-env-MouPnkRr.cjs +6 -0
- package/dist/strict-client-env-MouPnkRr.cjs.map +1 -0
- package/dist/{types-BzMGTYWv.d.ts → types-BfMBbrMm.d.ts} +2 -2
- package/dist/{types-BzMGTYWv.d.ts.map → types-BfMBbrMm.d.ts.map} +1 -1
- package/dist/{types-44R9mgTa.d.cts → types-BlRHnQwj.d.cts} +2 -2
- package/dist/{types-44R9mgTa.d.cts.map → types-BlRHnQwj.d.cts.map} +1 -1
- package/package.json +12 -5
- package/dist/arkenv-internal-Cll5pV_F.cjs +0 -2
- package/dist/arkenv-internal-Cll5pV_F.cjs.map +0 -1
- package/dist/arkenv-internal-DEN5DTmX.js +0 -2
- package/dist/arkenv-internal-DEN5DTmX.js.map +0 -1
- package/dist/config-CStvXoN3.cjs +0 -93
- package/dist/config-CStvXoN3.cjs.map +0 -1
- package/dist/config-D2j45WDh.js +0 -93
- package/dist/config-D2j45WDh.js.map +0 -1
- package/dist/index-BFQlm61W.d.ts.map +0 -1
- package/dist/index-CNzwVE5N.d.cts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-Oq8dsEPM.cjs","names":["path","resolveBuildLog","path","fs","path","path","fs","resolveBuildLog","missingClientTsError","formatBuildError","jiti","CLIENT_ENV_SPECIFIER","resolveLoggerFromOptions"],"sources":["../src/config/extract.ts","../src/config/generate.ts","../src/config/layout.ts","../src/config/codegen.ts","../src/config/strict-layout-aliases.ts","../src/config/setup.ts"],"sourcesContent":["import { extractBlock, parseBlockKeys } from \"@arkenv/build\";\n\nfunction parseExposeKeys(optionsArg: string): string[] {\n\tconst exposeMatch =\n\t\toptionsArg.match(/exposeToClient\\s*:\\s*\\[([\\s\\S]*?)\\]/) ||\n\t\toptionsArg.match(/expose\\s*:\\s*\\[([\\s\\S]*?)\\]/) ||\n\t\toptionsArg.match(/shared\\s*:\\s*\\[([\\s\\S]*?)\\]/);\n\tif (!exposeMatch) return [];\n\n\tconst keys: string[] = [];\n\tfor (const match of exposeMatch[1].matchAll(/['\"`](.*?)['\"`]/g)) {\n\t\tkeys.push(match[1]);\n\t}\n\treturn keys;\n}\n\nfunction extractCallArguments(\n\tcontent: string,\n): { schemaArg: string; optionsArg: string | null } | null {\n\tconst regex = /\\b(?:arkenv|createEnv)\\s*\\(/g;\n\twhile (regex.exec(content) !== null) {\n\t\tlet parenCount = 1;\n\t\tlet index = regex.lastIndex;\n\t\tlet inString: string | null = null;\n\t\tlet inComment: \"single\" | \"multi\" | null = null;\n\t\tlet braceCount = 0;\n\t\tlet bracketCount = 0;\n\n\t\tconst args: string[] = [];\n\t\tlet currentArg = \"\";\n\n\t\twhile (index < content.length && parenCount > 0) {\n\t\t\tconst char = content[index];\n\t\t\tconst nextChar = content[index + 1];\n\n\t\t\tif (inComment === \"single\") {\n\t\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\t\tcurrentArg += char;\n\t\t\t\tindex++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (inComment === \"multi\") {\n\t\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\t\tinComment = null;\n\t\t\t\t\tcurrentArg += \"*/\";\n\t\t\t\t\tindex += 2;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcurrentArg += char;\n\t\t\t\tindex++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (inString) {\n\t\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\t\tinString = null;\n\t\t\t\t}\n\t\t\t\tcurrentArg += char;\n\t\t\t\tindex++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\t\tinComment = \"single\";\n\t\t\t\tcurrentArg += \"//\";\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\t\tinComment = \"multi\";\n\t\t\t\tcurrentArg += \"/*\";\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\t\tinString = char;\n\t\t\t\tcurrentArg += char;\n\t\t\t\tindex++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (char === \"(\") {\n\t\t\t\tparenCount++;\n\t\t\t} else if (char === \")\") {\n\t\t\t\tparenCount--;\n\t\t\t} else if (char === \"{\") {\n\t\t\t\tbraceCount++;\n\t\t\t} else if (char === \"}\") {\n\t\t\t\tbraceCount--;\n\t\t\t} else if (char === \"[\") {\n\t\t\t\tbracketCount++;\n\t\t\t} else if (char === \"]\") {\n\t\t\t\tbracketCount--;\n\t\t\t}\n\n\t\t\tif (parenCount === 0) {\n\t\t\t\targs.push(currentArg);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tchar === \",\" &&\n\t\t\t\tparenCount === 1 &&\n\t\t\t\tbraceCount === 0 &&\n\t\t\t\tbracketCount === 0\n\t\t\t) {\n\t\t\t\targs.push(currentArg);\n\t\t\t\tcurrentArg = \"\";\n\t\t\t} else {\n\t\t\t\tcurrentArg += char;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\n\t\tif (parenCount === 0 && args.length > 0) {\n\t\t\treturn {\n\t\t\t\tschemaArg: args[0].trim(),\n\t\t\t\toptionsArg: args[1] ? args[1].trim() : null,\n\t\t\t};\n\t\t}\n\t}\n\treturn null;\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\tisLegacy?: boolean;\n} {\n\tconst clientKeys: string[] = [];\n\tconst sharedKeys: string[] = [];\n\n\tconst args = extractCallArguments(content);\n\tif (!args) {\n\t\treturn { clientKeys, sharedKeys, isLegacy: false };\n\t}\n\n\tconst trimmedSchema = args.schemaArg\n\t\t.replace(/^\\{/, \"\")\n\t\t.replace(/\\}$/, \"\")\n\t\t.trim();\n\tconst topKeys = parseBlockKeys(trimmedSchema);\n\tconst isLegacy =\n\t\ttopKeys.includes(\"client\") ||\n\t\ttopKeys.includes(\"server\") ||\n\t\ttopKeys.includes(\"shared\");\n\n\tif (isLegacy) {\n\t\tconst clientBlock = extractBlock(args.schemaArg, \"client\");\n\t\tif (clientBlock) clientKeys.push(...parseBlockKeys(clientBlock));\n\t\tconst sharedBlock = extractBlock(args.schemaArg, \"shared\");\n\t\tif (sharedBlock) sharedKeys.push(...parseBlockKeys(sharedBlock));\n\t\treturn { clientKeys, sharedKeys, isLegacy };\n\t}\n\n\tconst optionExposedKeys = args.optionsArg\n\t\t? parseExposeKeys(args.optionsArg)\n\t\t: [];\n\n\tfor (const key of topKeys) {\n\t\tif (optionExposedKeys.includes(key) || key === \"NODE_ENV\") {\n\t\t\tsharedKeys.push(key);\n\t\t\tcontinue;\n\t\t}\n\t\tif (key.startsWith(\"NEXT_PUBLIC_\")) {\n\t\t\tclientKeys.push(key);\n\t\t}\n\t}\n\n\treturn { clientKeys, sharedKeys, isLegacy };\n}\n","import path from \"node:path\";\n\nfunction generateRuntimeEnvLines(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\treturn allKeys\n\t\t.map(\n\t\t\t(key) =>\n\t\t\t\t`\\t\\t\\t${key}: typeof window !== \"undefined\" ? (globalThis as any).__arkenv_env__?.${key} ?? process.env.${key} : process.env.${key},`,\n\t\t)\n\t\t.join(\"\\n\");\n}\n\nconst GENERATED_HEADER = `/* eslint-disable */\n// biome-ignore format: auto-generated\n// Generated by ArkEnv. DO NOT EDIT DIRECTLY.\n`;\n\nconst GENERATED_FOOTER = `\nexport default arkenv;\n`;\n\nexport function generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n\tisStandard?: boolean,\n): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\tconst importPath = isStandard ? \"@arkenv/nextjs/standard\" : \"@arkenv/nextjs\";\n\tconst coreName = \"arkenv\";\n\tconst callPrefix = \"coreArkenv\";\n\n\treturn `${GENERATED_HEADER}\nimport { ${coreName} as coreArkenv } from \"${importPath}\";\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}) {\n\treturn ${callPrefix}({\n\t\t...options,\n\t\truntimeEnv: {\n\t\t\t${runtimeEnvLines}\n\t\t},\n\t} as any) as any;\n}\n${GENERATED_FOOTER}`;\n}\n\nexport function generateFlatFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n\tisStandard?: boolean,\n): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\tconst importPath = isStandard ? \"@arkenv/nextjs/standard\" : \"@arkenv/nextjs\";\n\tconst coreName = \"arkenv\";\n\tconst typeImport = isStandard\n\t\t? \"\"\n\t\t: '\\nimport type { type as at, distill } from \"arktype\";';\n\tconst returnType = isStandard\n\t\t? \"Readonly<TSchema>\"\n\t\t: \"Readonly<distill.Out<at.infer<TSchema>>>\";\n\tconst castReturn = isStandard\n\t\t? \"\"\n\t\t: \" as unknown as Readonly<distill.Out<at.infer<TSchema>>>\";\n\tconst callPrefix = \"coreArkenv\";\n\n\treturn `${GENERATED_HEADER}\nimport { ${coreName} as coreArkenv } from \"${importPath}\";${typeImport}\n\nexport function arkenv<\n\tconst TSchema extends Record<string, unknown> & { runtimeEnv?: never } = {},\n\tconst TExpose extends keyof TSchema = never,\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema,\n\toptions?: {\n\t\t/**\n\t\t * Custom environment variables to expose to the client bundle.\n\t\t * By default, variables prefixed with \\`NEXT_PUBLIC_\\` and \\`NODE_ENV\\` are exposed automatically.\n\t\t * Use this option to expose custom variables that do not have the \\`NEXT_PUBLIC_\\` prefix.\n\t\t */\n\t\texposeToClient?: readonly TExpose[];\n\t\textends?: [...TExtends];\n\t},\n): ${returnType} {\n\tconst env = ${callPrefix}(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n\t\t\t${runtimeEnvLines}\n\t\t},\n\t} as any);\n\treturn env${castReturn};\n}\n${GENERATED_FOOTER}`;\n}\n\n/**\n * Ambient module declaration so `#arkenv/client-env` resolves to the project's\n * `env/client.ts` for `AutoClientEnv` type inference on `@arkenv/nextjs/server`.\n *\n * @returns Generated `.d.ts` source\n */\nexport function generateClientEnvAmbientDeclaration(\n\tclientPath?: string,\n\toutputPath?: string,\n): string {\n\tlet importTarget = \"../client\";\n\tif (clientPath && outputPath) {\n\t\tconst ambientDir = path.dirname(outputPath);\n\t\tconst rel = path.relative(ambientDir, clientPath).replace(/\\\\/g, \"/\");\n\t\tconst cleanRel = rel.replace(/\\.tsx?$/, \"\");\n\t\timportTarget = cleanRel.startsWith(\".\") ? cleanRel : `./${cleanRel}`;\n\t}\n\treturn `${GENERATED_HEADER}\ndeclare module \"#arkenv/client-env\" {\n\texport { env } from \"${importTarget}\";\n}\n`;\n}\n\nexport function generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n\tisStandard?: boolean,\n): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\tconst importPath = isStandard\n\t\t? \"@arkenv/nextjs/standard/client\"\n\t\t: \"@arkenv/nextjs/client\";\n\tconst coreName = \"arkenv\";\n\tconst typeImport = isStandard\n\t\t? \"\"\n\t\t: '\\nimport type { Infer } from \"@arkenv/core\";';\n\tconst callPrefix = \"coreArkenv\";\n\tconst returnType = isStandard\n\t\t? \"Readonly<TSchema & MergeExtends<TExtends>>\"\n\t\t: \"Readonly<Infer<TSchema> & MergeExtends<TExtends>>\";\n\n\treturn `${GENERATED_HEADER}\nimport { ${coreName} as coreArkenv } from \"${importPath}\";${typeImport}\n\ntype ResolveExtend<T> = [Infer<T>] extends [never] ? T : Infer<T>;\n\ntype UnionToIntersection<U> = (\n\tU extends any ? (k: U) => void : never\n) extends (k: infer I) => void\n\t? I\n\t: never;\n\ntype MergeExtends<TExtends extends readonly unknown[] | undefined> =\n\tTExtends extends readonly unknown[]\n\t\t? UnionToIntersection<ResolveExtend<TExtends[number]>>\n\t\t: {};\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): ${returnType} {\n\treturn ${callPrefix}(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n\t\t\t${runtimeEnvLines}\n\t\t},\n\t} as any);\n}\n${GENERATED_FOOTER}`;\n}\n","import type { BuildLogHelpers } from \"@repo/log\";\nimport type { ArkEnvConfigOptions } from \"./types\";\n\nlet hasWarnedSimpleLayout = false;\n\nexport function normalizeLayout(\n\tlayout: ArkEnvConfigOptions[\"layout\"],\n\tbuildLog: BuildLogHelpers,\n): \"simple\" | \"strict\" | undefined {\n\tif (layout === \"flat\") return \"simple\";\n\tif (layout !== \"simple\") return layout;\n\n\tconst isDev = process.env.NODE_ENV === \"development\";\n\tif (!isDev || hasWarnedSimpleLayout) return \"simple\";\n\n\thasWarnedSimpleLayout = true;\n\tbuildLog.logBuildWarning(\n\t\t\"The 'simple' layout option is deprecated and will be removed in the next major version. Use 'flat' instead.\",\n\t);\n\treturn \"simple\";\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n\textractClientKeys,\n\textractSharedKeys,\n\tresolveLayout,\n} from \"@arkenv/build\";\nimport { resolveBuildLog } from \"@repo/log\";\nimport { extractKeys } from \"./extract\";\nimport {\n\tgenerateClientEnvAmbientDeclaration,\n\tgenerateClientFactoryCode,\n\tgenerateFactoryCode,\n\tgenerateFlatFactoryCode,\n} from \"./generate\";\nimport { normalizeLayout } from \"./layout\";\nimport type { ArkEnvConfigOptions } from \"./types\";\n\nfunction detectStandard(content: string, forceStandard?: boolean): boolean {\n\tif (forceStandard) return true;\n\treturn (\n\t\tcontent.includes(\"@arkenv/standard\") || content.includes(\"arkenv/standard\")\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 * @param forceStandard Force standard mode code generation\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?: ArkEnvConfigOptions[\"layout\"],\n\tforceStandard?: boolean,\n\tlogOptions?: Pick<ArkEnvConfigOptions, \"logger\" | \"logLevel\">,\n) {\n\tconst normalizedLayout = normalizeLayout(\n\t\tlayoutOption,\n\t\tresolveBuildLog(logOptions),\n\t);\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tnormalizedLayout,\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 isStandard =\n\t\t\tdetectStandard(clientContent, forceStandard) ||\n\t\t\tdetectStandard(sharedContent, forceStandard);\n\n\t\tconst clientKeys = extractClientKeys(clientContent);\n\t\tconst sharedKeys = extractSharedKeys(sharedContent);\n\n\t\tgeneratedCode = generateClientFactoryCode(\n\t\t\tclientKeys,\n\t\t\tsharedKeys,\n\t\t\tisStandard,\n\t\t);\n\t} else {\n\t\tconst fileContent = fs.readFileSync(schemaPath, \"utf-8\");\n\t\tconst isStandard = detectStandard(fileContent, forceStandard);\n\n\t\tconst { clientKeys, sharedKeys, isLegacy } = extractKeys(fileContent);\n\t\tif (isLegacy) {\n\t\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys, isStandard);\n\t\t} else {\n\t\t\tgeneratedCode = generateFlatFactoryCode(\n\t\t\t\tclientKeys,\n\t\t\t\tsharedKeys,\n\t\t\t\tisStandard,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\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\tconst barrelPath = path.join(outputDir, \"index.ts\");\n\tconst barrelCode = `export * from \"./env.gen\";\\nexport { default } from \"./env.gen\";\\n`;\n\tif (path.basename(outputDir) === \".arkenv\" || !fs.existsSync(barrelPath)) {\n\t\tlet shouldWriteBarrel = true;\n\t\tif (fs.existsSync(barrelPath)) {\n\t\t\tif (fs.readFileSync(barrelPath, \"utf-8\") === barrelCode) {\n\t\t\t\tshouldWriteBarrel = false;\n\t\t\t}\n\t\t}\n\t\tif (shouldWriteBarrel) {\n\t\t\tfs.writeFileSync(barrelPath, barrelCode, \"utf-8\");\n\t\t}\n\t}\n\n\tif (resolvedLayout === \"strict\" && baseDir) {\n\t\tconst ambientPath = path.join(\n\t\t\tpath.dirname(outputPath),\n\t\t\t\"arkenv-client-env.d.ts\",\n\t\t);\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst ambientCode = generateClientEnvAmbientDeclaration(\n\t\t\tclientPath,\n\t\t\toutputPath,\n\t\t);\n\t\tlet shouldWriteAmbient = true;\n\t\tif (fs.existsSync(ambientPath)) {\n\t\t\tif (fs.readFileSync(ambientPath, \"utf-8\") === ambientCode) {\n\t\t\t\tshouldWriteAmbient = false;\n\t\t\t}\n\t\t}\n\t\tif (shouldWriteAmbient) {\n\t\t\tfs.writeFileSync(ambientPath, ambientCode, \"utf-8\");\n\t\t}\n\t}\n}\n","import path from \"node:path\";\nimport type { CLIENT_ENV_SPECIFIER } from \"../strict-client-env\";\n\ntype WebpackConfigLike = {\n\tresolve?: {\n\t\talias?:\n\t\t\t| Record<string, string | false | string[]>\n\t\t\t| Array<{ name: string; alias: string | false | string[] }>;\n\t};\n\tplugins?: unknown[];\n};\n\ntype WebpackLike = {\n\tDefinePlugin: new (definitions: Record<string, string>) => unknown;\n};\n\ntype WebpackContextLike = {\n\twebpack?: WebpackLike;\n};\n\ntype TurbopackResolveAlias = Record<string, string | string[]>;\n\ntype NextConfigLike = {\n\twebpack?: (\n\t\tconfig: WebpackConfigLike,\n\t\tcontext: WebpackContextLike,\n\t) => WebpackConfigLike | undefined;\n\tturbopack?: {\n\t\tresolveAlias?: TurbopackResolveAlias;\n\t\t[key: string]: unknown;\n\t};\n\texperimental?: {\n\t\tturbo?: {\n\t\t\tresolveAlias?: TurbopackResolveAlias;\n\t\t\t[key: string]: unknown;\n\t\t};\n\t\t[key: string]: unknown;\n\t};\n\tenv?: Record<string, string | undefined>;\n\t[key: string]: unknown;\n};\n\n/**\n * Merge `#arkenv/client-env` into a webpack `resolve.alias` value (object or array form).\n *\n * @param alias Existing webpack resolve.alias\n * @param specifier Virtual module specifier\n * @param target Absolute path to the project client env module\n * @returns Updated alias value\n */\nfunction mergeWebpackAlias(\n\talias:\n\t\t| Record<string, string | false | string[]>\n\t\t| Array<{ name: string; alias: string | false | string[] }>\n\t\t| undefined,\n\tspecifier: string,\n\ttarget: string,\n):\n\t| Record<string, string | false | string[]>\n\t| Array<{ name: string; alias: string | false | string[] }> {\n\tif (Array.isArray(alias)) {\n\t\tconst next = alias.filter((entry) => entry.name !== specifier);\n\t\tnext.push({ name: specifier, alias: target });\n\t\treturn next;\n\t}\n\treturn {\n\t\t...(alias ?? {}),\n\t\t[specifier]: target,\n\t};\n}\n\n/**\n * Apply webpack + Turbopack aliases and a compile-time strict-layout flag.\n *\n * Chains any existing `webpack` function on the user config. Turbopack aliases\n * are written to both `turbopack.resolveAlias` (Next 15+) and\n * `experimental.turbo.resolveAlias` for older configs.\n *\n * @param nextConfig User Next.js config object\n * @param clientEnvPath Absolute path to `env/client.ts`\n * @param specifier Virtual module specifier (typically `#arkenv/client-env`)\n * @returns Next config with strict-layout alias wiring\n */\nexport function applyStrictLayoutAliases<T extends NextConfigLike>(\n\tnextConfig: T,\n\tclientEnvPath: string,\n\tspecifier: typeof CLIENT_ENV_SPECIFIER | string = \"#arkenv/client-env\",\n): T {\n\tconst previousWebpack = nextConfig.webpack;\n\n\tconst webpack = (config: WebpackConfigLike, context: WebpackContextLike) => {\n\t\tconst resolved = previousWebpack\n\t\t\t? (previousWebpack(config, context) ?? config)\n\t\t\t: config;\n\t\tresolved.resolve = resolved.resolve ?? {};\n\t\tresolved.resolve.alias = mergeWebpackAlias(\n\t\t\tresolved.resolve.alias,\n\t\t\tspecifier,\n\t\t\tclientEnvPath,\n\t\t);\n\n\t\tconst DefinePlugin = context.webpack?.DefinePlugin;\n\t\tif (DefinePlugin) {\n\t\t\tresolved.plugins = resolved.plugins ?? [];\n\t\t\tresolved.plugins.push(\n\t\t\t\tnew DefinePlugin({\n\t\t\t\t\t__ARKENV_STRICT_LAYOUT__: JSON.stringify(true),\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\treturn resolved;\n\t};\n\n\tconst turbopackTarget = path.isAbsolute(clientEnvPath)\n\t\t? `./${path.relative(process.cwd(), clientEnvPath).replace(/\\\\/g, \"/\")}`\n\t\t: clientEnvPath.startsWith(\".\")\n\t\t\t? clientEnvPath\n\t\t\t: `./${clientEnvPath}`;\n\n\tconst existingTurbopack = nextConfig.turbopack ?? {};\n\tconst turbopackResolveAlias: TurbopackResolveAlias = {\n\t\t...(existingTurbopack.resolveAlias ?? {}),\n\t\t[specifier]: turbopackTarget,\n\t};\n\n\tconst existingExperimental = nextConfig.experimental;\n\tconst experimental = existingExperimental\n\t\t? {\n\t\t\t\t...existingExperimental,\n\t\t\t\t...(existingExperimental.turbo\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tturbo: {\n\t\t\t\t\t\t\t\t...existingExperimental.turbo,\n\t\t\t\t\t\t\t\tresolveAlias: {\n\t\t\t\t\t\t\t\t\t...(existingExperimental.turbo.resolveAlias ?? {}),\n\t\t\t\t\t\t\t\t\t[specifier]: turbopackTarget,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}\n\t\t: undefined;\n\n\t// Spread as a plain object. Callers must pass a resolved config object —\n\t// `withArkEnv` awaits function-form `next.config` before calling this.\n\tconst result: Record<string, unknown> = {\n\t\t...nextConfig,\n\t\twebpack,\n\t\t// Turbopack / non-webpack paths: surface the flag via Next env inlining.\n\t\t// Note: Next.js forbids keys with __ prefix in nextConfig.env, so we use\n\t\t// ARKENV_STRICT_LAYOUT (no underscores) here. The webpack DefinePlugin\n\t\t// path uses __ARKENV_STRICT_LAYOUT__ as a compile-time literal, which is fine.\n\t\tenv: {\n\t\t\t...(nextConfig.env ?? {}),\n\t\t\tARKENV_STRICT_LAYOUT: \"true\",\n\t\t},\n\t\tturbopack: {\n\t\t\t...existingTurbopack,\n\t\t\tresolveAlias: turbopackResolveAlias,\n\t\t},\n\t};\n\n\tif (experimental) {\n\t\tresult.experimental = experimental;\n\t}\n\n\treturn result as T;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n\tfindSchemaPath,\n\tformatMissingSchemaError,\n\tresolveLayout,\n\twatchSchema,\n} from \"@arkenv/build\";\nimport {\n\tformatBuildError,\n\tresolveBuildLog,\n\tresolveLoggerFromOptions,\n} from \"@repo/log\";\nimport { createJiti } from \"jiti\";\nimport {\n\tCLIENT_ENV_SPECIFIER,\n\tmissingClientTsError,\n} from \"../strict-client-env\";\nimport { runCodegen } from \"./codegen\";\nimport { normalizeLayout } from \"./layout\";\nimport { applyStrictLayoutAliases } from \"./strict-layout-aliases\";\nimport type {\n\tArkEnvConfigOptions,\n\tNextConfigContext,\n\tNextConfigFactory,\n} from \"./types\";\n\nfunction resolveMockServerOnlyPath(moduleDir: string): string {\n\tfor (const base of [moduleDir, path.join(moduleDir, \"..\")]) {\n\t\tconst tsPath = path.join(base, \"mock-server-only.ts\");\n\t\tif (fs.existsSync(tsPath)) {\n\t\t\treturn tsPath;\n\t\t}\n\t\tconst jsPath = path.join(base, \"mock-server-only.js\");\n\t\tif (fs.existsSync(jsPath)) {\n\t\t\treturn jsPath;\n\t\t}\n\t}\n\n\treturn path.join(moduleDir, \"mock-server-only.js\");\n}\n\nfunction resolveEmptyClientEnvPath(moduleDir: string): string {\n\tfor (const base of [moduleDir, path.join(moduleDir, \"..\")]) {\n\t\tconst tsPath = path.join(base, \"empty-client-env.ts\");\n\t\tif (fs.existsSync(tsPath)) {\n\t\t\treturn tsPath;\n\t\t}\n\t\tconst jsPath = path.join(base, \"empty-client-env.js\");\n\t\tif (fs.existsSync(jsPath)) {\n\t\t\treturn jsPath;\n\t\t}\n\t}\n\n\treturn path.join(moduleDir, \"empty-client-env.js\");\n}\n\nfunction schemaPathExists(schemaPath: string): boolean {\n\tif (fs.existsSync(schemaPath)) return true;\n\n\tconst ext = path.extname(schemaPath);\n\tif (!ext) return false;\n\n\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\treturn fs.existsSync(baseWithoutExt);\n}\n\ntype SetupResult = {\n\tresolvedLayout: \"flat\" | \"strict\" | \"simple\";\n\tbaseDir: string | undefined;\n\tclientEnvPath: string | undefined;\n\toutputPath: string;\n};\n\n/**\n * Run ArkEnv codegen and setup without wrapping nextConfig.\n *\n * @param options Optional configuration paths for schema and output files\n * @param internalOptions Optional configuration for internal testing hooks\n * @returns Resolved layout paths used by `withArkEnv` for alias registration\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function setupArkEnv(\n\toptions?: ArkEnvConfigOptions,\n\tinternalOptions?: { _jitiAliases?: Record<string, string> },\n): SetupResult {\n\tconst buildLog = resolveBuildLog(options);\n\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\tif (!schemaPath || !schemaPathExists(schemaPath)) {\n\t\tthrow new Error(\n\t\t\tformatMissingSchemaError({\n\t\t\t\tschemaPath: options?.schemaPath,\n\t\t\t\toptionsHint: \"setupArkEnv options\",\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst normalizedLayout = normalizeLayout(options?.layout, buildLog);\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tnormalizedLayout,\n\t);\n\n\tconst clientEnvPath =\n\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t? path.join(baseDir, \"client.ts\")\n\t\t\t: undefined;\n\n\tif (clientEnvPath && !fs.existsSync(clientEnvPath)) {\n\t\tthrow new Error(missingClientTsError(clientEnvPath, baseDir!));\n\t}\n\n\tfunction resolveProjectRoot(\n\t\tschema: string,\n\t\tbase?: string,\n\t\tlayout?: string,\n\t): string {\n\t\tif (layout === \"strict\" && base) {\n\t\t\tlet dir = base;\n\t\t\tif (path.basename(dir) === \"env\") {\n\t\t\t\tdir = path.dirname(dir);\n\t\t\t}\n\t\t\tif (path.basename(dir) === \"src\") {\n\t\t\t\tdir = path.dirname(dir);\n\t\t\t}\n\t\t\treturn dir;\n\t\t}\n\t\tlet dir = path.dirname(schema);\n\t\tif (path.basename(dir) === \"src\") {\n\t\t\tdir = path.dirname(dir);\n\t\t}\n\t\treturn dir;\n\t}\n\n\tconst projectRoot = resolveProjectRoot(schemaPath, baseDir, resolvedLayout);\n\tconst defaultOutputPath = path.join(projectRoot, \".arkenv\", \"env.gen.ts\");\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\tconst codegen = options?.codegen ?? true;\n\tif (codegen) {\n\t\ttry {\n\t\t\trunCodegen(\n\t\t\t\tschemaPath,\n\t\t\t\toutputPath,\n\t\t\t\tresolvedLayout,\n\t\t\t\toptions?.standard,\n\t\t\t\toptions,\n\t\t\t);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(\n\t\t\t\tformatBuildError(`Failed to generate env.gen.ts: ${message}`),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst runValidation = options?.validate ?? true;\n\tif (runValidation) {\n\t\tconst g = globalThis as {\n\t\t\t__arkenv_force_server__?: boolean;\n\t\t\t__ARKENV_STRICT_LAYOUT__?: boolean;\n\t\t\t__ARKENV_CLIENT_ENV__?: unknown;\n\t\t};\n\t\ttry {\n\t\t\tg.__arkenv_force_server__ = true;\n\t\t\tconst fileToEvaluate =\n\t\t\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t\t\t? path.join(baseDir, \"server.ts\")\n\t\t\t\t\t: schemaPath;\n\n\t\t\tconst filenameForJiti =\n\t\t\t\ttypeof __filename !== \"undefined\"\n\t\t\t\t\t? __filename\n\t\t\t\t\t: typeof import.meta !== \"undefined\" && import.meta.url\n\t\t\t\t\t\t? fileURLToPath(import.meta.url)\n\t\t\t\t\t\t: \"\";\n\t\t\tconst dir = path.dirname(filenameForJiti);\n\t\t\tconst mockServerOnlyPath = resolveMockServerOnlyPath(dir);\n\t\t\tconst emptyClientEnvPath = resolveEmptyClientEnvPath(dir);\n\n\t\t\tconst aliases: Record<string, string> = {\n\t\t\t\t\"server-only\": mockServerOnlyPath,\n\t\t\t\t\"./script\": mockServerOnlyPath,\n\t\t\t\t\"./script.tsx\": mockServerOnlyPath,\n\t\t\t\t[CLIENT_ENV_SPECIFIER]:\n\t\t\t\t\tclientEnvPath && fs.existsSync(clientEnvPath)\n\t\t\t\t\t\t? clientEnvPath\n\t\t\t\t\t\t: emptyClientEnvPath,\n\t\t\t\t...internalOptions?._jitiAliases,\n\t\t\t};\n\n\t\t\tconst jiti = createJiti(fileToEvaluate, {\n\t\t\t\tmoduleCache: false,\n\t\t\t\tfsCache: false,\n\t\t\t\ttsconfigPaths: true,\n\t\t\t\talias: aliases,\n\t\t\t});\n\n\t\t\tif (resolvedLayout === \"strict\" && clientEnvPath) {\n\t\t\t\tg.__ARKENV_STRICT_LAYOUT__ = true;\n\t\t\t\tconst clientMod = jiti(clientEnvPath) as {\n\t\t\t\t\tenv?: unknown;\n\t\t\t\t\tdefault?: { env?: unknown };\n\t\t\t\t};\n\t\t\t\tg.__ARKENV_CLIENT_ENV__ =\n\t\t\t\t\tclientMod.env ?? clientMod.default?.env ?? clientMod;\n\t\t\t}\n\n\t\t\tjiti(fileToEvaluate);\n\t\t} catch (error: unknown) {\n\t\t\tbuildLog.logBuildError(\"Environment validation failed:\");\n\t\t\tbuildLog.logBuildErrorDetail(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t\tbuildLog.logBuildErrorBlankLine();\n\t\t\tprocess.exit(1);\n\t\t} finally {\n\t\t\tdelete g.__arkenv_force_server__;\n\t\t\tdelete g.__ARKENV_STRICT_LAYOUT__;\n\t\t\tdelete g.__ARKENV_CLIENT_ENV__;\n\t\t}\n\t}\n\n\tconst isDev =\n\t\tprocess.env.NODE_ENV === \"development\" ||\n\t\tprocess.env.NEXT_PHASE === \"phase-development-server\";\n\tif (isDev && codegen) {\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(\n\t\t\twatchPaths,\n\t\t\t() => {\n\t\t\t\trunCodegen(\n\t\t\t\t\tschemaPath,\n\t\t\t\t\toutputPath,\n\t\t\t\t\tresolvedLayout,\n\t\t\t\t\toptions?.standard,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t},\n\t\t\tresolveLoggerFromOptions(options),\n\t\t);\n\t}\n\n\treturn {\n\t\tresolvedLayout,\n\t\tbaseDir,\n\t\tclientEnvPath,\n\t\toutputPath,\n\t};\n}\n\ntype AliasableNextConfig = Record<string, unknown> & {\n\tturbopack?: {\n\t\tresolveAlias?: Record<string, unknown>;\n\t\t[key: string]: unknown;\n\t};\n\twebpack?: (webpackConfig: never, context: never) => unknown;\n};\n\n/**\n * Apply strict-layout and virtual `.arkenv/` aliases to a resolved Next.js config object.\n *\n * @param configObj The resolved Next.js configuration object\n * @param options Optional configuration paths for schema and output files\n * @param setup Result of `setupArkEnv` for the current invocation\n * @returns The configuration object with webpack and Turbopack aliases\n */\nfunction applyArkEnvAliases<T extends object>(\n\tconfigObj: T,\n\toptions: ArkEnvConfigOptions | undefined,\n\tsetup: SetupResult,\n): T {\n\tconst { resolvedLayout, clientEnvPath, outputPath: targetGenPath } = setup;\n\tlet currentConfig = configObj as AliasableNextConfig;\n\n\tif (resolvedLayout === \"strict\" && clientEnvPath) {\n\t\tcurrentConfig = applyStrictLayoutAliases(\n\t\t\tcurrentConfig as never,\n\t\t\tclientEnvPath,\n\t\t\tCLIENT_ENV_SPECIFIER,\n\t\t) as AliasableNextConfig;\n\t}\n\n\tconst rootDir = process.cwd();\n\tconst targetGenPathToUse =\n\t\ttargetGenPath ??\n\t\t(options?.outputPath\n\t\t\t? path.resolve(options.outputPath)\n\t\t\t: path.join(rootDir, \".arkenv\", \"env.gen.ts\"));\n\tconst relativeGenPath = `./${path.relative(rootDir, targetGenPathToUse).replace(/\\\\/g, \"/\")}`;\n\n\tconst turbopack = {\n\t\t...currentConfig.turbopack,\n\t\tresolveAlias: {\n\t\t\t\".arkenv/env.gen\": relativeGenPath,\n\t\t\t\".arkenv/env.gen.ts\": relativeGenPath,\n\t\t\t\".arkenv\": relativeGenPath,\n\t\t\t\".arkenv/index\": relativeGenPath,\n\t\t\t\".arkenv/index.ts\": relativeGenPath,\n\t\t\t\"#arkenv/env\": relativeGenPath,\n\t\t\t\"@/.arkenv\": relativeGenPath,\n\t\t\t\"@/.arkenv/env.gen\": relativeGenPath,\n\t\t\t...currentConfig.turbopack?.resolveAlias,\n\t\t},\n\t};\n\n\tconst previousWebpack = currentConfig.webpack;\n\tconst webpack = (webpackConfig: never, context: never) => {\n\t\tconst resolvedConfig = webpackConfig as {\n\t\t\tresolve?: { alias?: Record<string, unknown> };\n\t\t};\n\t\tresolvedConfig.resolve = resolvedConfig.resolve ?? {};\n\t\tresolvedConfig.resolve.alias = {\n\t\t\t...resolvedConfig.resolve.alias,\n\t\t\t\".arkenv/env.gen\": targetGenPathToUse,\n\t\t\t\".arkenv/env.gen.ts\": targetGenPathToUse,\n\t\t\t\".arkenv\": targetGenPathToUse,\n\t\t\t\".arkenv/index\": targetGenPathToUse,\n\t\t\t\".arkenv/index.ts\": targetGenPathToUse,\n\t\t\t\"#arkenv/env\": targetGenPathToUse,\n\t\t\t\"@/.arkenv\": targetGenPathToUse,\n\t\t\t\"@/.arkenv/env.gen\": targetGenPathToUse,\n\t\t};\n\t\tif (typeof previousWebpack === \"function\") {\n\t\t\treturn previousWebpack(resolvedConfig as never, context);\n\t\t}\n\t\treturn resolvedConfig;\n\t};\n\n\treturn {\n\t\t...currentConfig,\n\t\tturbopack,\n\t\twebpack,\n\t} as unknown as T;\n}\n\n/**\n * Wrap a Next.js configuration object or function to generate `runtimeEnv` in\n * `env.gen.ts`, register `#arkenv/client-env` in strict layout for auto-extend,\n * and configure Turbopack/Webpack aliases for virtualized `.arkenv/` placement.\n *\n * Function-form configs (sync or async) are preserved: ArkEnv awaits the user's\n * factory, then applies aliases to the resolved object.\n *\n * @param nextConfig The Next.js configuration object or `(phase, context)` factory\n * @param options Optional configuration paths for schema and output files\n * @returns The Next.js configuration object, or an async factory that resolves to it\n * @throws An error if the schema file cannot be found or if code generation fails\n *\n * @example\n * ```ts\n * export default withArkEnv({ reactStrictMode: true });\n *\n * export default withArkEnv(async (phase, { defaultConfig }) => ({\n * ...defaultConfig,\n * reactStrictMode: phase !== \"phase-test\",\n * }));\n * ```\n */\nexport function withArkEnv<T extends object>(\n\tnextConfig: NextConfigFactory<T>,\n\toptions?: ArkEnvConfigOptions,\n): (phase: string, context: NextConfigContext) => Promise<T>;\nexport function withArkEnv<T extends object>(\n\tnextConfig: T,\n\toptions?: ArkEnvConfigOptions,\n): T;\nexport function withArkEnv<T extends object>(\n\tnextConfig: T | NextConfigFactory<T>,\n\toptions?: ArkEnvConfigOptions,\n): T | ((phase: string, context: NextConfigContext) => Promise<T>) {\n\tif (typeof nextConfig === \"function\") {\n\t\treturn async (phase: string, context: NextConfigContext) => {\n\t\t\tconst setup = setupArkEnv(options);\n\t\t\tconst resolved = await nextConfig(phase, context);\n\t\t\treturn applyArkEnvAliases(resolved, options, setup);\n\t\t};\n\t}\n\n\tif (nextConfig && typeof nextConfig === \"object\") {\n\t\tconst setup = setupArkEnv(options);\n\t\treturn applyArkEnvAliases(nextConfig, options, setup);\n\t}\n\n\treturn nextConfig;\n}\n"],"mappings":"gsBAEA,SAAS,EAAgB,EAA8B,CACtD,IAAM,EACL,EAAW,MAAM,sCAAsC,EACvD,EAAW,MAAM,8BAA8B,EAC/C,EAAW,MAAM,8BAA8B,CAChD,GAAI,CAAC,EAAa,MAAO,EAAE,CAE3B,IAAM,EAAiB,EAAE,CACzB,IAAK,IAAM,KAAS,EAAY,GAAG,SAAS,mBAAmB,CAC9D,EAAK,KAAK,EAAM,GAAG,CAEpB,OAAO,EAGR,SAAS,EACR,EAC0D,CAC1D,IAAM,EAAQ,+BACd,KAAO,EAAM,KAAK,EAAQ,GAAK,MAAM,CACpC,IAAI,EAAa,EACb,EAAQ,EAAM,UACd,EAA0B,KAC1B,EAAuC,KACvC,EAAa,EACb,EAAe,EAEb,EAAiB,EAAE,CACrB,EAAa,GAEjB,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,GAAc,EACd,IACA,SAED,GAAI,IAAc,QAAS,CAC1B,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,KACZ,GAAc,KACd,GAAS,EACT,SAED,GAAc,EACd,IACA,SAGD,GAAI,EAAU,CACT,I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,iBAAgB,gBAAe,WAAY,GAAkB,EACjE,EAAgB,EAEhB,IAAmB,UAAY,IAClC,EAAgB,EACf,EACA,EACAD,EAAAA,EACA,EAGF,IAAM,EAAU,QAAQ,KAAK,CACvB,EACL,IACC,GAAS,WACPN,EAAAA,QAAK,QAAQ,EAAQ,WAAW,CAChCA,EAAAA,QAAK,KAAK,EAAS,UAAW,aAAa,EACzC,EAAkB,KAAKA,EAAAA,QAAK,SAAS,EAAS,EAAmB,CAAC,QAAQ,MAAO,IAAI,GAErF,EAAY,CACjB,GAAG,EAAc,UACjB,aAAc,CACb,kBAAmB,EACnB,qBAAsB,EACtB,UAAW,EACX,gBAAiB,EACjB,mBAAoB,EACpB,cAAe,EACf,YAAa,EACb,oBAAqB,EACrB,GAAG,EAAc,WAAW,aAC5B,CACD,CAEK,EAAkB,EAAc,QAChC,GAAW,EAAsB,IAAmB,CACzD,IAAM,EAAiB,EAkBvB,MAfA,GAAe,QAAU,EAAe,SAAW,EAAE,CACrD,EAAe,QAAQ,MAAQ,CAC9B,GAAG,EAAe,QAAQ,MAC1B,kBAAmB,EACnB,qBAAsB,EACtB,UAAW,EACX,gBAAiB,EACjB,mBAAoB,EACpB,cAAe,EACf,YAAa,EACb,oBAAqB,EACrB,CACG,OAAO,GAAoB,WACvB,EAAgB,EAAyB,EAAQ,CAElD,GAGR,MAAO,CACN,GAAG,EACH,YACA,UACA,CAkCF,SAAgB,EACf,EACA,EACkE,CAclE,OAbI,OAAO,GAAe,WAClB,MAAO,EAAe,IAA+B,CAC3D,IAAM,EAAQ,EAAY,EAAQ,CAElC,OAAO,EAAmB,MADH,EAAW,EAAO,EAAQ,CACb,EAAS,EAAM,EAIjD,GAAc,OAAO,GAAe,SAEhC,EAAmB,EAAY,EADxB,EAAY,EAC0B,CAAC,CAG/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-client-env.cjs","names":[],"sources":["../src/empty-client-env.ts"],"sourcesContent":["/**\n * Empty client env used when `#arkenv/client-env` is imported outside strict\n * layout (so the server entry can keep a static import without the bundler\n * failing to resolve the virtual specifier).\n */\nexport const env = {};\n"],"mappings":"mEAKA,MAAa,EAAM,EAAE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/empty-client-env.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Empty client env used when `#arkenv/client-env` is imported outside strict
|
|
4
|
+
* layout (so the server entry can keep a static import without the bundler
|
|
5
|
+
* failing to resolve the virtual specifier).
|
|
6
|
+
*/
|
|
7
|
+
declare const env: {};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { env };
|
|
10
|
+
//# sourceMappingURL=empty-client-env.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-client-env.d.cts","names":[],"sources":["../src/empty-client-env.ts"],"mappings":";;AAKA;;;;cAAa,GAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/empty-client-env.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Empty client env used when `#arkenv/client-env` is imported outside strict
|
|
4
|
+
* layout (so the server entry can keep a static import without the bundler
|
|
5
|
+
* failing to resolve the virtual specifier).
|
|
6
|
+
*/
|
|
7
|
+
declare const env: {};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { env };
|
|
10
|
+
//# sourceMappingURL=empty-client-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-client-env.d.ts","names":[],"sources":["../src/empty-client-env.ts"],"mappings":";;AAKA;;;;cAAa,GAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-client-env.js","names":[],"sources":["../src/empty-client-env.ts"],"sourcesContent":["/**\n * Empty client env used when `#arkenv/client-env` is imported outside strict\n * layout (so the server entry can keep a static import without the bundler\n * failing to resolve the virtual specifier).\n */\nexport const env = {};\n"],"mappings":"AAKA,MAAa,EAAM,EAAE"}
|
|
@@ -93,79 +93,139 @@ type Dict<T> = Record<string, T | undefined>;
|
|
|
93
93
|
* Copied from standard-schema (MIT License)
|
|
94
94
|
* Copyright (c) 2024 Colin McDannell
|
|
95
95
|
*/
|
|
96
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* The Standard Typed interface. This is a base type extended by other specs.
|
|
98
|
+
*/
|
|
97
99
|
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
98
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* The Standard properties.
|
|
102
|
+
*/
|
|
99
103
|
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
100
104
|
}
|
|
101
105
|
declare namespace StandardTypedV1 {
|
|
102
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* The Standard Typed properties interface.
|
|
108
|
+
*/
|
|
103
109
|
interface Props<Input = unknown, Output = Input> {
|
|
104
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* The version number of the standard.
|
|
112
|
+
*/
|
|
105
113
|
readonly version: 1;
|
|
106
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* The vendor name of the schema library.
|
|
116
|
+
*/
|
|
107
117
|
readonly vendor: string;
|
|
108
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Inferred types associated with the schema.
|
|
120
|
+
*/
|
|
109
121
|
readonly types?: Types<Input, Output> | undefined;
|
|
110
122
|
}
|
|
111
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* The Standard Typed types interface.
|
|
125
|
+
*/
|
|
112
126
|
interface Types<Input = unknown, Output = Input> {
|
|
113
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* The input type of the schema.
|
|
129
|
+
*/
|
|
114
130
|
readonly input: Input;
|
|
115
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* The output type of the schema.
|
|
133
|
+
*/
|
|
116
134
|
readonly output: Output;
|
|
117
135
|
}
|
|
118
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Infers the input type of a Standard Typed.
|
|
138
|
+
*/
|
|
119
139
|
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
120
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* Infers the output type of a Standard Typed.
|
|
142
|
+
*/
|
|
121
143
|
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
122
144
|
}
|
|
123
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* The Standard Schema interface.
|
|
147
|
+
*/
|
|
124
148
|
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
125
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* The Standard Schema properties.
|
|
151
|
+
*/
|
|
126
152
|
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
127
153
|
}
|
|
128
154
|
declare namespace StandardSchemaV1 {
|
|
129
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* The Standard Schema properties interface.
|
|
157
|
+
*/
|
|
130
158
|
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
131
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Validates unknown input values.
|
|
161
|
+
*/
|
|
132
162
|
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
133
163
|
}
|
|
134
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* The result interface of the validate function.
|
|
166
|
+
*/
|
|
135
167
|
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
136
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* The result interface if validation succeeds.
|
|
170
|
+
*/
|
|
137
171
|
interface SuccessResult<Output> {
|
|
138
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* The typed output value.
|
|
174
|
+
*/
|
|
139
175
|
readonly value: Output;
|
|
140
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* A falsy value for `issues` indicates success.
|
|
178
|
+
*/
|
|
141
179
|
readonly issues?: undefined;
|
|
142
180
|
}
|
|
143
181
|
interface Options {
|
|
144
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Explicit support for additional vendor-specific parameters, if needed.
|
|
184
|
+
*/
|
|
145
185
|
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
146
186
|
}
|
|
147
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* The result interface if validation fails.
|
|
189
|
+
*/
|
|
148
190
|
interface FailureResult {
|
|
149
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* The issues of failed validation.
|
|
193
|
+
*/
|
|
150
194
|
readonly issues: ReadonlyArray<Issue>;
|
|
151
195
|
}
|
|
152
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* The issue interface of the failure output.
|
|
198
|
+
*/
|
|
153
199
|
interface Issue {
|
|
154
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* The error message of the issue.
|
|
202
|
+
*/
|
|
155
203
|
readonly message: string;
|
|
156
|
-
/**
|
|
204
|
+
/**
|
|
205
|
+
* The path of the issue, if any.
|
|
206
|
+
*/
|
|
157
207
|
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
158
208
|
}
|
|
159
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* The path segment interface of the issue.
|
|
211
|
+
*/
|
|
160
212
|
interface PathSegment {
|
|
161
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* The key representing a path segment.
|
|
215
|
+
*/
|
|
162
216
|
readonly key: PropertyKey;
|
|
163
217
|
}
|
|
164
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The Standard types interface.
|
|
220
|
+
*/
|
|
165
221
|
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
166
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Infers the input type of a Standard.
|
|
224
|
+
*/
|
|
167
225
|
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
168
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* Infers the output type of a Standard.
|
|
228
|
+
*/
|
|
169
229
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
170
230
|
}
|
|
171
231
|
//#endregion
|
|
@@ -187,4 +247,4 @@ type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Out
|
|
|
187
247
|
type SchemaShape = Record<string, unknown>;
|
|
188
248
|
//#endregion
|
|
189
249
|
export { $ as a, Dict as i, InferType as n, StandardSchemaV1 as r, SchemaShape as t };
|
|
190
|
-
//# sourceMappingURL=index-
|
|
250
|
+
//# sourceMappingURL=index-BS1wAitS.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BS1wAitS.d.cts","names":["_$arktype","_$arktype_internal_keywords_string_ts0","_$arktype_internal_attributes_ts0","$","trim","To","Submodule","normalize","capitalize","stringDate","stringInteger","ip","stringJson","lower","stringNumeric","url","uuid","Scope","string","In","root","alpha","alphanumeric","hex","base64","creditCard","date","digits","email","integer","json","numeric","regex","semver","upper","preformatted","host","number","NaN","Infinity","epoch","safe","NegativeInfinity","port","Dict","T","Record","StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema","target","type","Dict","StandardSchemaV1","InferType","T","errors","Any","_Input","Output","value","R","t","U","_Scope","$","Type","SchemaShape","Record","CompiledEnvSchema"],"sources":["../../internal/scope/dist/index.d.ts","../../internal/types/dist/helpers.d.ts","../../internal/types/dist/standard-schema.d.ts","../../internal/types/dist/infer-type.d.ts","../../internal/types/dist/schema.d.ts"],"mappings":";;;;;;;;AAEoF;;;;cAQtEG,CAAAA,EAAGH,SAAAA,CAAUiB,KA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A,SEmENqE,MAAAA,EAAQN,aAAAA,CAAcD,KAAAA;EAAAA;EFhEnCzD;;;EAAAA,UEqEUyD,KAAAA;IFrEqDzD;;;IAAAA,SEyElDkE,OAAAA;IFtEP7E;;;IAAAA,SE0EO8E,IAAAA,GAAOT,aAAAA,CAAcC,WAAAA,GAAcC,WAAAA;EAAAA;EFzE9C;;;EAAA,UE8EQA,WAAAA;IF5EiBtE;;;IAAAA,SEgFd8E,GAAAA,EAAKT,WAAAA;EAAAA;EF/EgBpE;;;EAAAA,UEoFxBkD,KAAAA,2BAAgCJ,KAAAA,UAAeD,eAAAA,CAAgBK,KAAAA,CAAMJ,KAAAA,EAAOC,MAAAA;EFlFzDhD;;;EAAAA,KEuFxB0D,UAAAA,gBAA0BZ,eAAAA,IAAmBA,eAAAA,CAAgBY,UAAAA,CAAWR,MAAAA;EFpF7EnB;;;EAAAA,KEwFK4B,WAAAA,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,CAAYT,MAAAA;AAAAA;;;;;;AF1IC;;;;;;KGUxEqC,SAAAA,MAAeC,CAAAA,SAAUF,gBAAAA,+BAA+CM,MAAAA,GAASJ,CAAAA,WAAWK,KAAAA,EAAOR,IAAAA,wBAA2BS,CAAAA,SAAUV,IAAAA,CAAKK,MAAAA,WAAiBK,CAAAA,GAAIN,CAAAA;EAC1KO,CAAAA;AAAAA,IACAC,CAAAA,GAAIR,CAAAA,SAAUJ,IAAAA,CAAKM,GAAAA,0BAA6BM,CAAAA;;;KCZxCI,WAAAA,GAAcC,MAAAA"}
|
|
@@ -3,12 +3,12 @@ import { extractClientKeys as extractClientKeys$1, extractSharedKeys as extractS
|
|
|
3
3
|
//#region ../internal/log/dist/index.d.ts
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Supported log level thresholds, from most to least verbose.
|
|
8
|
+
*/
|
|
7
9
|
type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
8
10
|
/**
|
|
9
11
|
* Shared logger interface for ArkEnv packages.
|
|
10
|
-
*
|
|
11
|
-
* CLI-specific features (spinners, JSON reporters, `flush`) stay outside this type.
|
|
12
12
|
*/
|
|
13
13
|
type Logger = {
|
|
14
14
|
debug: (message: string, ...optionalParams: unknown[]) => void;
|
|
@@ -16,9 +16,24 @@ type Logger = {
|
|
|
16
16
|
warn: (message: string, ...optionalParams: unknown[]) => void;
|
|
17
17
|
error: (message: string, ...optionalParams: unknown[]) => void;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Programmatic logger configuration. Takes precedence over `ARKENV_LOG_LEVEL`.
|
|
21
|
+
*/
|
|
20
22
|
//#endregion
|
|
21
23
|
//#region src/config/types.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* Context object Next.js passes to a function-form `next.config`.
|
|
26
|
+
*
|
|
27
|
+
* `defaultConfig` is `{}` so callers can spread it while remaining a
|
|
28
|
+
* supertype of Next.js's `NextConfig` interface.
|
|
29
|
+
*/
|
|
30
|
+
type NextConfigContext = {
|
|
31
|
+
defaultConfig: {};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Function-form Next.js config: sync or async, receiving the current phase.
|
|
35
|
+
*/
|
|
36
|
+
type NextConfigFactory<T extends object = object> = (phase: string, context: NextConfigContext) => T | Promise<T>;
|
|
22
37
|
/**
|
|
23
38
|
* Configuration options for the ArkEnv Next.js integration.
|
|
24
39
|
*
|
|
@@ -26,7 +41,6 @@ type Logger = {
|
|
|
26
41
|
* ```ts
|
|
27
42
|
* const configOptions: ArkEnvConfigOptions = {
|
|
28
43
|
* schemaPath: "./src/env.ts",
|
|
29
|
-
* outputPath: "./src/generated/env.gen.ts"
|
|
30
44
|
* };
|
|
31
45
|
* ```
|
|
32
46
|
*/
|
|
@@ -54,7 +68,6 @@ type ArkEnvConfigOptions = {
|
|
|
54
68
|
* @example
|
|
55
69
|
* ```ts
|
|
56
70
|
* export default withArkEnv(nextConfig, {
|
|
57
|
-
* outputPath: "./src/generated/env.gen.ts"
|
|
58
71
|
* });
|
|
59
72
|
* ```
|
|
60
73
|
*/
|
|
@@ -67,7 +80,11 @@ type ArkEnvConfigOptions = {
|
|
|
67
80
|
*
|
|
68
81
|
* @default "flat"
|
|
69
82
|
*/
|
|
70
|
-
layout?: "flat" | "strict"
|
|
83
|
+
layout?: "flat" | "strict"
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use `"flat"` instead. `"simple"` will be removed in the next major version.
|
|
86
|
+
*/
|
|
87
|
+
| "simple";
|
|
71
88
|
/**
|
|
72
89
|
* Force standard mode code generation.
|
|
73
90
|
*
|
|
@@ -131,25 +148,48 @@ declare function extractKeys(content: string): {
|
|
|
131
148
|
};
|
|
132
149
|
//#endregion
|
|
133
150
|
//#region src/config/setup.d.ts
|
|
151
|
+
type SetupResult = {
|
|
152
|
+
resolvedLayout: "flat" | "strict" | "simple";
|
|
153
|
+
baseDir: string | undefined;
|
|
154
|
+
clientEnvPath: string | undefined;
|
|
155
|
+
outputPath: string;
|
|
156
|
+
};
|
|
134
157
|
/**
|
|
135
158
|
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
136
159
|
*
|
|
137
160
|
* @param options Optional configuration paths for schema and output files
|
|
138
161
|
* @param internalOptions Optional configuration for internal testing hooks
|
|
162
|
+
* @returns Resolved layout paths used by `withArkEnv` for alias registration
|
|
139
163
|
* @throws An error if the schema file cannot be found or if code generation fails
|
|
140
164
|
*/
|
|
141
165
|
declare function setupArkEnv(options?: ArkEnvConfigOptions, internalOptions?: {
|
|
142
166
|
_jitiAliases?: Record<string, string>;
|
|
143
|
-
}):
|
|
167
|
+
}): SetupResult;
|
|
144
168
|
/**
|
|
145
|
-
* Wrap a Next.js configuration object to
|
|
169
|
+
* Wrap a Next.js configuration object or function to generate `runtimeEnv` in
|
|
170
|
+
* `env.gen.ts`, register `#arkenv/client-env` in strict layout for auto-extend,
|
|
171
|
+
* and configure Turbopack/Webpack aliases for virtualized `.arkenv/` placement.
|
|
172
|
+
*
|
|
173
|
+
* Function-form configs (sync or async) are preserved: ArkEnv awaits the user's
|
|
174
|
+
* factory, then applies aliases to the resolved object.
|
|
146
175
|
*
|
|
147
|
-
* @param nextConfig The Next.js configuration object or
|
|
176
|
+
* @param nextConfig The Next.js configuration object or `(phase, context)` factory
|
|
148
177
|
* @param options Optional configuration paths for schema and output files
|
|
149
|
-
* @returns The Next.js configuration object
|
|
178
|
+
* @returns The Next.js configuration object, or an async factory that resolves to it
|
|
150
179
|
* @throws An error if the schema file cannot be found or if code generation fails
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* export default withArkEnv({ reactStrictMode: true });
|
|
184
|
+
*
|
|
185
|
+
* export default withArkEnv(async (phase, { defaultConfig }) => ({
|
|
186
|
+
* ...defaultConfig,
|
|
187
|
+
* reactStrictMode: phase !== "phase-test",
|
|
188
|
+
* }));
|
|
189
|
+
* ```
|
|
151
190
|
*/
|
|
152
|
-
declare function withArkEnv<T>(nextConfig: T
|
|
191
|
+
declare function withArkEnv<T extends object>(nextConfig: NextConfigFactory<T>, options?: ArkEnvConfigOptions): (phase: string, context: NextConfigContext) => Promise<T>;
|
|
192
|
+
declare function withArkEnv<T extends object>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
153
193
|
//#endregion
|
|
154
|
-
export { extractKeys as a, withArkEnv as i, extractSharedKeys$1 as n, runCodegen as o, setupArkEnv as r, ArkEnvConfigOptions as s, extractClientKeys$1 as t };
|
|
155
|
-
//# sourceMappingURL=index-
|
|
194
|
+
export { extractKeys as a, NextConfigContext as c, withArkEnv as i, NextConfigFactory as l, extractSharedKeys$1 as n, runCodegen as o, setupArkEnv as r, ArkEnvConfigOptions as s, extractClientKeys$1 as t };
|
|
195
|
+
//# sourceMappingURL=index-CBjJM83X.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CBjJM83X.d.ts","names":["formatErrorCause","cause","logErrorWithCauseVia","message","log","header","LogLevel","Logger","debug","optionalParams","info","warn","error","LoggerConfig","level","BUILD_PREFIX","WATCHER_PREFIX","formatBuildError","BuildLogHelpers","logBuildWarning","logBuildError","logBuildErrorDetail","logBuildErrorBlankLine","logBuildErrorWithCause","logWatcherError","logWatcherErrorWithCause","createBuildLogHelpers","logger","resolveLogger","bindDefaultBuildLog","isNode","shouldDisableColors","createConsoleLogger","config","defaultLogger","configureDefaultLogger","ArkEnvLogOptions","logLevel","ArkEnvPluginConfig","T","Record","splitPluginConfig","pluginConfig","logOptions","resolveLoggerFromOptions","options","resolveBuildLog","parseLogLevel","value","readEnvLogLevel","resolveLogLevel","shouldLog","Exclude","configuredLevel","messageLevel"],"sources":["../../internal/log/dist/index.d.ts","../src/config/types.ts","../src/config/codegen.ts","../src/config/extract.ts","../src/config/setup.ts"],"mappings":";;;;;;;;KAgBKM,QAAAA;;;;KAIAC,MAAAA;EACHC,KAAAA,GAAQL,OAAAA,aAAoBM,cAAAA;EAC5BC,IAAAA,GAAOP,OAAAA,aAAoBM,cAAAA;EAC3BE,IAAAA,GAAOR,OAAAA,aAAoBM,cAAAA;EAC3BG,KAAAA,GAAQT,OAAAA,aAAoBM,cAAAA;AAAAA;;;;;;;;AAdsE;;;;KCFxF,iBAAA;EACX,aAAA;AAAA;;;;KAMW,iBAAA,+BACX,KAAA,UACA,OAAA,EAAS,iBAAA,KACL,CAAA,GAAI,OAAA,CAAQ,CAAA;;;;;;;;;;;KAYL,mBAAA;EDNgC;;;;AChB5C;;;;;AAOA;;;;EA6BC,UAAA;EA1BgB;;;;;;;;;;;;EAwChB,UAAA;EA5BW;;;;;;;;EAsCX,MAAA;EAgCA;;;EAAA;EAcW;;;;;;AChFZ;;;;EDoDC,QAAA;EC/Ca;;;;;EDsDb,QAAA;ECxDA;;;;;ED+DA,OAAA;EC7D6D;;;;AC2F9D;EFvBC,MAAA,GAAS,MAAA;;;;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