@arkenv/nextjs 1.0.0-alpha.0 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -0
- package/README.md +3 -1
- package/dist/arkenv-internal-Cll5pV_F.cjs +2 -0
- package/dist/arkenv-internal-Cll5pV_F.cjs.map +1 -0
- package/dist/arkenv-internal-DEN5DTmX.js +2 -0
- package/dist/arkenv-internal-DEN5DTmX.js.map +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +13 -11
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +13 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/config/index.cjs +1 -0
- package/dist/config/index.d.cts +2 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +1 -0
- package/dist/config-CStvXoN3.cjs +93 -0
- package/dist/config-CStvXoN3.cjs.map +1 -0
- package/dist/config-D2j45WDh.js +93 -0
- package/dist/config-D2j45WDh.js.map +1 -0
- package/dist/dist-Bof1Std7.cjs +2 -0
- package/dist/dist-Bof1Std7.cjs.map +1 -0
- package/dist/dist-DimRGXOV.js +2 -0
- package/dist/dist-DimRGXOV.js.map +1 -0
- package/dist/{index-Bn3pRiJy.d.ts → index-96RGPyfa.d.cts} +6 -3
- package/dist/index-96RGPyfa.d.cts.map +1 -0
- package/dist/index-BFQlm61W.d.ts +155 -0
- package/dist/index-BFQlm61W.d.ts.map +1 -0
- package/dist/index-CNzwVE5N.d.cts +155 -0
- package/dist/index-CNzwVE5N.d.cts.map +1 -0
- package/dist/{index-C6bpQ5GU.d.cts → index-bjEZwPUt.d.ts} +6 -3
- package/dist/index-bjEZwPUt.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -16
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +32 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mock-server-only.cjs +2 -0
- package/dist/mock-server-only.cjs.map +1 -0
- package/dist/mock-server-only.d.cts +1 -0
- package/dist/mock-server-only.d.ts +1 -0
- package/dist/mock-server-only.js +2 -0
- package/dist/mock-server-only.js.map +1 -0
- package/dist/react-server.cjs +1 -1
- package/dist/react-server.cjs.map +1 -1
- package/dist/react-server.d.cts +25 -16
- package/dist/react-server.d.cts.map +1 -1
- package/dist/react-server.d.ts +25 -16
- 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 +21 -0
- package/dist/script-7FFqInPq.d.ts.map +1 -0
- package/dist/script-BHFJ0MU_.d.cts +21 -0
- package/dist/script-BHFJ0MU_.d.cts.map +1 -0
- package/dist/script-CZOPkAw3.js +2 -0
- package/dist/script-CZOPkAw3.js.map +1 -0
- package/dist/script-D-MYC2Uf.cjs +2 -0
- package/dist/script-D-MYC2Uf.cjs.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +14 -12
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +14 -12
- 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 +2 -0
- package/dist/standard/client.cjs.map +1 -0
- package/dist/standard/client.d.cts +30 -0
- package/dist/standard/client.d.cts.map +1 -0
- package/dist/standard/client.d.ts +30 -0
- package/dist/standard/client.d.ts.map +1 -0
- package/dist/standard/client.js +2 -0
- package/dist/standard/client.js.map +1 -0
- package/dist/standard/config.cjs +2 -0
- package/dist/standard/config.cjs.map +1 -0
- package/dist/standard/config.d.cts +14 -0
- package/dist/standard/config.d.cts.map +1 -0
- package/dist/standard/config.d.ts +14 -0
- package/dist/standard/config.d.ts.map +1 -0
- package/dist/standard/config.js +2 -0
- package/dist/standard/config.js.map +1 -0
- package/dist/standard/index.cjs +2 -0
- package/dist/standard/index.cjs.map +1 -0
- package/dist/standard/index.d.cts +35 -0
- package/dist/standard/index.d.cts.map +1 -0
- package/dist/standard/index.d.ts +35 -0
- package/dist/standard/index.d.ts.map +1 -0
- package/dist/standard/index.js +2 -0
- package/dist/standard/index.js.map +1 -0
- package/dist/standard/server.cjs +2 -0
- package/dist/standard/server.cjs.map +1 -0
- package/dist/standard/server.d.cts +18 -0
- package/dist/standard/server.d.cts.map +1 -0
- package/dist/standard/server.d.ts +18 -0
- package/dist/standard/server.d.ts.map +1 -0
- package/dist/standard/server.js +2 -0
- package/dist/standard/server.js.map +1 -0
- package/dist/standard/shared.cjs +2 -0
- package/dist/standard/shared.cjs.map +1 -0
- package/dist/standard/shared.d.cts +13 -0
- package/dist/standard/shared.d.cts.map +1 -0
- package/dist/standard/shared.d.ts +13 -0
- package/dist/standard/shared.d.ts.map +1 -0
- package/dist/standard/shared.js +2 -0
- package/dist/standard/shared.js.map +1 -0
- package/dist/{types-DBqiLw5v.d.cts → types-44R9mgTa.d.cts} +2 -2
- package/dist/{types-DBqiLw5v.d.cts.map → types-44R9mgTa.d.cts.map} +1 -1
- package/dist/{types-BN4fEChy.d.ts → types-BzMGTYWv.d.ts} +2 -2
- package/dist/{types-BN4fEChy.d.ts.map → types-BzMGTYWv.d.ts.map} +1 -1
- package/package.json +67 -30
- package/dist/config.cjs +0 -78
- package/dist/config.cjs.map +0 -1
- package/dist/config.d.cts +0 -107
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.ts +0 -107
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -78
- package/dist/config.js.map +0 -1
- package/dist/create-env-BfXQtLQM.js +0 -2
- package/dist/create-env-BfXQtLQM.js.map +0 -1
- package/dist/create-env-DDWVuzwL.cjs +0 -2
- package/dist/create-env-DDWVuzwL.cjs.map +0 -1
- package/dist/index-Bn3pRiJy.d.ts.map +0 -1
- package/dist/index-C6bpQ5GU.d.cts.map +0 -1
- package/dist/shared.cjs +0 -2
- package/dist/shared.cjs.map +0 -1
- package/dist/shared.d.cts +0 -17
- package/dist/shared.d.cts.map +0 -1
- package/dist/shared.d.ts +0 -17
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -2
- package/dist/shared.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-D2j45WDh.js","names":["resolveBuildLog","resolveBuildLog","formatBuildError","resolveLoggerFromOptions"],"sources":["../src/config/extract.ts","../src/config/generate.ts","../src/config/layout.ts","../src/config/codegen.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","function 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\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\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","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 { runCodegen } from \"./codegen\";\nimport { normalizeLayout } from \"./layout\";\nimport type { ArkEnvConfigOptions } 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 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\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 * @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): void {\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 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\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\ttry {\n\t\t\t(globalThis as any).__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\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...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\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 (globalThis as any).__arkenv_force_server__;\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\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\tsetupArkEnv(options);\n\treturn nextConfig;\n}\n"],"mappings":"maAEA,SAAS,EAAgB,EAA8B,CACtD,IAAM,EACL,EAAW,MAAM,sCAAsC,EACvD,EAAW,MAAM,8BAA8B,EAC/C,EAAW,MAAM,8BAA8B,CAChD,GAAI,CAA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a,eACzB,QAAQ,IAAI,aAAe,6BACf,GASZ,EAPC,IAAmB,UAAY,EAC5B,CACA,EAAK,KAAK,EAAS,WAAY,YAAY,CAC3C,EAAK,KAAK,EAAS,YAAY,CAC/B,EAAK,KAAK,EAAS,YAAY,CAC/B,CAAC,OAAO,EAAG,WAAW,CACtB,CAAC,EAAW,KAGT,CACL,EACC,EACA,EACA,EACA,GAAS,SACT,EACA,EAEFC,EAAyB,EAAQ,CACjC,CAYH,SAAgB,EAAc,EAAe,EAAkC,CAE9E,OADA,EAAY,EAAQ,CACb"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e instanceof Error?e.stack??e.message:String(e)}const t={debug:0,info:1,warn:2,error:3},n=new Set([`debug`,`info`,`warn`,`error`,`silent`]);function r(e){if(!e)return;let t=e.trim().toLowerCase();if(n.has(t))return t}function i(){if(!(typeof process>`u`))return r(process.env?.ARKENV_LOG_LEVEL)}function a(e){return e?.level??i()??`info`}function o(e,n){return e===`silent`?!1:t[n]>=t[e]}function s(e,t,n){return(r,...i)=>{o(e,t)&&console[n](r,...i)}}function c(e){let t=a(e);return{debug:s(t,`debug`,`debug`),info:s(t,`info`,`info`),warn:s(t,`warn`,`warn`),error:s(t,`error`,`error`)}}let l=c();const u=`[ArkEnv]`,d=`[ArkEnv Watcher]`;function f(e){return`${u} ${e}`}function p(t){return{logBuildWarning(e){t.warn(`⚠️ ${u} ${e}`)},logBuildError(e){t.error(`❌ ${u} ${e}`)},logBuildErrorDetail(e){t.error(e)},logBuildErrorBlankLine(){t.error(``)},logBuildErrorWithCause(n,r){t.error(`❌ ${u} ${n}`),t.error(e(r))},logWatcherError(e){t.error(`${d} ${e}`)},logWatcherErrorWithCause(n,r){t.error(`${d} ${n}`),t.error(e(r))}}}function m(e){return e??l}let h=p(l);function g(e){h.logBuildWarning(e)}function _(e){return e?.logger?e.logger:e?.logLevel?c({level:e.logLevel}):m()}function v(e){return p(_(e))}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
|
|
2
|
+
//# sourceMappingURL=dist-Bof1Std7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-Bof1Std7.cjs","names":[],"sources":["../../internal/log/dist/index.js"],"sourcesContent":["function e(e){return e instanceof Error?e.stack??e.message:String(e)}function t(e,t,n){e(`${t}: ${n instanceof Error?n.message:String(n)}`),n instanceof Error&&n.stack&&e(n.stack)}const n={debug:0,info:1,warn:2,error:3},r=new Set([`debug`,`info`,`warn`,`error`,`silent`]);function i(e){if(!e)return;let t=e.trim().toLowerCase();if(r.has(t))return t}function a(){if(!(typeof process>`u`))return i(process.env?.ARKENV_LOG_LEVEL)}function o(e){return e?.level??a()??`info`}function s(e,t){return e===`silent`?!1:n[t]>=n[e]}function c(e,t,n){return(r,...i)=>{s(e,t)&&console[n](r,...i)}}function l(e){let t=o(e);return{debug:c(t,`debug`,`debug`),info:c(t,`info`,`info`),warn:c(t,`warn`,`warn`),error:c(t,`error`,`error`)}}let u=l();function d(e){u=e}const f=`[ArkEnv]`,p=`[ArkEnv Watcher]`;function m(e){return`${f} ${e}`}function h(t){return{logBuildWarning(e){t.warn(`⚠️ ${f} ${e}`)},logBuildError(e){t.error(`❌ ${f} ${e}`)},logBuildErrorDetail(e){t.error(e)},logBuildErrorBlankLine(){t.error(``)},logBuildErrorWithCause(n,r){t.error(`❌ ${f} ${n}`),t.error(e(r))},logWatcherError(e){t.error(`${p} ${e}`)},logWatcherErrorWithCause(n,r){t.error(`${p} ${n}`),t.error(e(r))}}}function g(e){return e??u}let _=h(u);function v(e){_=h(e)}function y(e){_.logBuildWarning(e)}function b(e){_.logBuildError(e)}function x(e){_.logBuildErrorDetail(e)}function S(){_.logBuildErrorBlankLine()}function C(e,t){_.logBuildErrorWithCause(e,t)}function w(e){_.logWatcherError(e)}function T(e,t){_.logWatcherErrorWithCause(e,t)}const E=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function D(){if(!E())return!0;let e=process.env;return e.FORCE_COLOR===`0`?!0:e.FORCE_COLOR!==void 0&&e.FORCE_COLOR!==`0`?!1:!!(e.NO_COLOR!==void 0||e.CI!==void 0||process.stdout&&!process.stdout.isTTY)}function O(e,t){let n=t??l(e);d(n),v(n)}function k(e){if(!e)return{pluginConfig:{},logOptions:{}};let{logger:t,logLevel:n,...r}=e,i={};return t!==void 0&&(i.logger=t),n!==void 0&&(i.logLevel=n),{pluginConfig:r,logOptions:i}}function A(e){return e?.logger?e.logger:e?.logLevel?l({level:e.logLevel}):g()}function j(e){return h(A(e))}export{f as BUILD_PREFIX,p as WATCHER_PREFIX,v as bindDefaultBuildLog,O as configureDefaultLogger,h as createBuildLogHelpers,l as createConsoleLogger,u as defaultLogger,m as formatBuildError,e as formatErrorCause,E as isNode,b as logBuildError,S as logBuildErrorBlankLine,x as logBuildErrorDetail,C as logBuildErrorWithCause,y as logBuildWarning,t as logErrorWithCauseVia,w as logWatcherError,T as logWatcherErrorWithCause,i as parseLogLevel,a as readEnvLogLevel,j as resolveBuildLog,o as resolveLogLevel,g as resolveLogger,A as resolveLoggerFromOptions,D as shouldDisableColors,s as shouldLog,k as splitPluginConfig};\n//# sourceMappingURL=index.js.map"],"mappings":"AAAA,SAAS,EAAE,EAAE,CAAC,OAAO,aAAa,MAAM,EAAE,OAAO,EAAE,QAAQ,OAAO,EAAE,CAAgH,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,OAAO,OAAO,QAAQ,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,CAA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S,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAsB,SAAS,EAAE,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAivB,SAAS,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e instanceof Error?e.stack??e.message:String(e)}const t={debug:0,info:1,warn:2,error:3},n=new Set([`debug`,`info`,`warn`,`error`,`silent`]);function r(e){if(!e)return;let t=e.trim().toLowerCase();if(n.has(t))return t}function i(){if(!(typeof process>`u`))return r(process.env?.ARKENV_LOG_LEVEL)}function a(e){return e?.level??i()??`info`}function o(e,n){return e===`silent`?!1:t[n]>=t[e]}function s(e,t,n){return(r,...i)=>{o(e,t)&&console[n](r,...i)}}function c(e){let t=a(e);return{debug:s(t,`debug`,`debug`),info:s(t,`info`,`info`),warn:s(t,`warn`,`warn`),error:s(t,`error`,`error`)}}let l=c();const u=`[ArkEnv]`,d=`[ArkEnv Watcher]`;function f(e){return`${u} ${e}`}function p(t){return{logBuildWarning(e){t.warn(`⚠️ ${u} ${e}`)},logBuildError(e){t.error(`❌ ${u} ${e}`)},logBuildErrorDetail(e){t.error(e)},logBuildErrorBlankLine(){t.error(``)},logBuildErrorWithCause(n,r){t.error(`❌ ${u} ${n}`),t.error(e(r))},logWatcherError(e){t.error(`${d} ${e}`)},logWatcherErrorWithCause(n,r){t.error(`${d} ${n}`),t.error(e(r))}}}function m(e){return e??l}let h=p(l);function g(e){h.logBuildWarning(e)}function _(e){return e?.logger?e.logger:e?.logLevel?c({level:e.logLevel}):m()}function v(e){return p(_(e))}export{g as i,v as n,f as r,_ as t};
|
|
2
|
+
//# sourceMappingURL=dist-DimRGXOV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-DimRGXOV.js","names":[],"sources":["../../internal/log/dist/index.js"],"sourcesContent":["function e(e){return e instanceof Error?e.stack??e.message:String(e)}function t(e,t,n){e(`${t}: ${n instanceof Error?n.message:String(n)}`),n instanceof Error&&n.stack&&e(n.stack)}const n={debug:0,info:1,warn:2,error:3},r=new Set([`debug`,`info`,`warn`,`error`,`silent`]);function i(e){if(!e)return;let t=e.trim().toLowerCase();if(r.has(t))return t}function a(){if(!(typeof process>`u`))return i(process.env?.ARKENV_LOG_LEVEL)}function o(e){return e?.level??a()??`info`}function s(e,t){return e===`silent`?!1:n[t]>=n[e]}function c(e,t,n){return(r,...i)=>{s(e,t)&&console[n](r,...i)}}function l(e){let t=o(e);return{debug:c(t,`debug`,`debug`),info:c(t,`info`,`info`),warn:c(t,`warn`,`warn`),error:c(t,`error`,`error`)}}let u=l();function d(e){u=e}const f=`[ArkEnv]`,p=`[ArkEnv Watcher]`;function m(e){return`${f} ${e}`}function h(t){return{logBuildWarning(e){t.warn(`⚠️ ${f} ${e}`)},logBuildError(e){t.error(`❌ ${f} ${e}`)},logBuildErrorDetail(e){t.error(e)},logBuildErrorBlankLine(){t.error(``)},logBuildErrorWithCause(n,r){t.error(`❌ ${f} ${n}`),t.error(e(r))},logWatcherError(e){t.error(`${p} ${e}`)},logWatcherErrorWithCause(n,r){t.error(`${p} ${n}`),t.error(e(r))}}}function g(e){return e??u}let _=h(u);function v(e){_=h(e)}function y(e){_.logBuildWarning(e)}function b(e){_.logBuildError(e)}function x(e){_.logBuildErrorDetail(e)}function S(){_.logBuildErrorBlankLine()}function C(e,t){_.logBuildErrorWithCause(e,t)}function w(e){_.logWatcherError(e)}function T(e,t){_.logWatcherErrorWithCause(e,t)}const E=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null;function D(){if(!E())return!0;let e=process.env;return e.FORCE_COLOR===`0`?!0:e.FORCE_COLOR!==void 0&&e.FORCE_COLOR!==`0`?!1:!!(e.NO_COLOR!==void 0||e.CI!==void 0||process.stdout&&!process.stdout.isTTY)}function O(e,t){let n=t??l(e);d(n),v(n)}function k(e){if(!e)return{pluginConfig:{},logOptions:{}};let{logger:t,logLevel:n,...r}=e,i={};return t!==void 0&&(i.logger=t),n!==void 0&&(i.logLevel=n),{pluginConfig:r,logOptions:i}}function A(e){return e?.logger?e.logger:e?.logLevel?l({level:e.logLevel}):g()}function j(e){return h(A(e))}export{f as BUILD_PREFIX,p as WATCHER_PREFIX,v as bindDefaultBuildLog,O as configureDefaultLogger,h as createBuildLogHelpers,l as createConsoleLogger,u as defaultLogger,m as formatBuildError,e as formatErrorCause,E as isNode,b as logBuildError,S as logBuildErrorBlankLine,x as logBuildErrorDetail,C as logBuildErrorWithCause,y as logBuildWarning,t as logErrorWithCauseVia,w as logWatcherError,T as logWatcherErrorWithCause,i as parseLogLevel,a as readEnvLogLevel,j as resolveBuildLog,o as resolveLogLevel,g as resolveLogger,A as resolveLoggerFromOptions,D as shouldDisableColors,s as shouldLog,k as splitPluginConfig};\n//# sourceMappingURL=index.js.map"],"mappings":"AAAA,SAAS,EAAE,EAAE,CAAC,OAAO,aAAa,MAAM,EAAE,OAAO,EAAE,QAAQ,OAAO,EAAE,CAAgH,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,OAAO,OAAO,QAAQ,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,GAAG,CAAC,GAAG,EAAE,OAAO,QAAQ,KAAK,OAAO,EAAE,QAAQ,KAAK,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,GAAG,OAAO,GAAG,EAAE,OAAO,SAAS,EAAE,EAAE,EAAE,CAAC,OAAO,IA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AM,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -83,6 +83,9 @@ declare const $: _$arktype.Scope<{
|
|
|
83
83
|
}>;
|
|
84
84
|
type $ = (typeof $)["t"]; //#endregion
|
|
85
85
|
//#endregion
|
|
86
|
+
//#region ../internal/types/dist/helpers.d.ts
|
|
87
|
+
type Dict<T> = Record<string, T | undefined>;
|
|
88
|
+
//#endregion
|
|
86
89
|
//#region ../internal/types/dist/standard-schema.d.ts
|
|
87
90
|
/**
|
|
88
91
|
* @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec
|
|
@@ -176,12 +179,12 @@ declare namespace StandardSchemaV1 {
|
|
|
176
179
|
*
|
|
177
180
|
* @template T - The schema definition to infer from
|
|
178
181
|
*/
|
|
179
|
-
type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value:
|
|
182
|
+
type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Dict<string>) => infer R) ? R extends type.errors ? never : R : T extends {
|
|
180
183
|
t: infer U;
|
|
181
184
|
} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
|
|
182
185
|
//#endregion
|
|
183
186
|
//#region ../internal/types/dist/schema.d.ts
|
|
184
187
|
type SchemaShape = Record<string, unknown>;
|
|
185
188
|
//#endregion
|
|
186
|
-
export { InferType as n,
|
|
187
|
-
//# sourceMappingURL=index-
|
|
189
|
+
export { $ as a, Dict as i, InferType as n, StandardSchemaV1 as r, SchemaShape as t };
|
|
190
|
+
//# sourceMappingURL=index-96RGPyfa.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-96RGPyfa.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,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;MAChBc,IAAAA;MACAL,GAAAA;IAAAA;MAEA,cAAA;IAAA;IAEFP,UAAAA,EAAYR,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCO,UAAAA,CAAWL,CAAA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UF,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"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { extractClientKeys as extractClientKeys$1, extractSharedKeys as extractSharedKeys$1 } from "@arkenv/build";
|
|
2
|
+
|
|
3
|
+
//#region ../internal/log/dist/index.d.ts
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/** Supported log level thresholds, from most to least verbose. */
|
|
7
|
+
type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
8
|
+
/**
|
|
9
|
+
* Shared logger interface for ArkEnv packages.
|
|
10
|
+
*
|
|
11
|
+
* CLI-specific features (spinners, JSON reporters, `flush`) stay outside this type.
|
|
12
|
+
*/
|
|
13
|
+
type Logger = {
|
|
14
|
+
debug: (message: string, ...optionalParams: unknown[]) => void;
|
|
15
|
+
info: (message: string, ...optionalParams: unknown[]) => void;
|
|
16
|
+
warn: (message: string, ...optionalParams: unknown[]) => void;
|
|
17
|
+
error: (message: string, ...optionalParams: unknown[]) => void;
|
|
18
|
+
};
|
|
19
|
+
/** Programmatic logger configuration. Takes precedence over `ARKENV_LOG_LEVEL`. */
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/config/types.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Configuration options for the ArkEnv Next.js integration.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const configOptions: ArkEnvConfigOptions = {
|
|
28
|
+
* schemaPath: "./src/env.ts",
|
|
29
|
+
* outputPath: "./src/generated/env.gen.ts"
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
type ArkEnvConfigOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Specify the path to the schema definition file.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to searching for `"src/env.ts"` or `"env.ts"` in the project root.
|
|
38
|
+
*
|
|
39
|
+
* @default "src/env.ts"
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* export default withArkEnv(nextConfig, {
|
|
43
|
+
* schemaPath: "./src/env.ts"
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
schemaPath?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Specify the path where the generated file (`env.gen.ts`) should be written.
|
|
50
|
+
*
|
|
51
|
+
* Defaults to `"generated/env.gen.ts"` in the same directory as the schema file.
|
|
52
|
+
*
|
|
53
|
+
* @default "[schemaDirectory]/generated/env.gen.ts"
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* export default withArkEnv(nextConfig, {
|
|
57
|
+
* outputPath: "./src/generated/env.gen.ts"
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
outputPath?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Specify the configuration layout.
|
|
64
|
+
*
|
|
65
|
+
* - `"flat"` (default): A single `env.ts` schema file.
|
|
66
|
+
* - `"strict"`: A split schema layout (`env/client.ts`, `env/server.ts`, and optionally `env/internal/shared.ts`).
|
|
67
|
+
*
|
|
68
|
+
* @default "flat"
|
|
69
|
+
*/
|
|
70
|
+
layout?: "flat" | "strict" /** @deprecated Use `"flat"` instead. `"simple"` will be removed in the next major version. */ | "simple";
|
|
71
|
+
/**
|
|
72
|
+
* Force standard mode code generation.
|
|
73
|
+
*
|
|
74
|
+
* When `true`, the generated `env.gen.ts` imports from `@arkenv/nextjs/standard/*`
|
|
75
|
+
* instead of `@arkenv/nextjs/*`, ensuring the Standard Schema engine (`@arkenv/standard`)
|
|
76
|
+
* is used and `arktype` is never bundled. This is set automatically when importing from
|
|
77
|
+
* `@arkenv/nextjs/standard/config`, but can be toggled manually for custom setups.
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
standard?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Enable or disable build-time environment variable validation during build/dev startup.
|
|
84
|
+
*
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
validate?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Enable or disable automatic code generation of the `env.gen.ts` file.
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
codegen?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Custom logger instance for build-time messages.
|
|
96
|
+
*
|
|
97
|
+
* When omitted, ArkEnv uses a console logger respecting `ARKENV_LOG_LEVEL`.
|
|
98
|
+
*/
|
|
99
|
+
logger?: Logger;
|
|
100
|
+
/**
|
|
101
|
+
* Minimum log level for build-time messages.
|
|
102
|
+
*
|
|
103
|
+
* Programmatic `logger` takes precedence over `logLevel`.
|
|
104
|
+
*/
|
|
105
|
+
logLevel?: LogLevel;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/config/codegen.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* Run code generation to read the schema file and generate the env.gen.ts factory.
|
|
111
|
+
*
|
|
112
|
+
* @param schemaPath The absolute path to the schema file or directory
|
|
113
|
+
* @param outputPath The absolute path to the generated output file
|
|
114
|
+
* @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted
|
|
115
|
+
* @param forceStandard Force standard mode code generation
|
|
116
|
+
* @throws An error if strict layout files are missing when `layoutOption` is `"strict"`
|
|
117
|
+
*/
|
|
118
|
+
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: ArkEnvConfigOptions["layout"], forceStandard?: boolean, logOptions?: Pick<ArkEnvConfigOptions, "logger" | "logLevel">): void;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/config/extract.d.ts
|
|
121
|
+
/**
|
|
122
|
+
* Statically extract client and shared keys from the schema content.
|
|
123
|
+
*
|
|
124
|
+
* @param content The schema file string content
|
|
125
|
+
* @returns An object containing the extracted client and shared keys
|
|
126
|
+
*/
|
|
127
|
+
declare function extractKeys(content: string): {
|
|
128
|
+
clientKeys: string[];
|
|
129
|
+
sharedKeys: string[];
|
|
130
|
+
isLegacy?: boolean;
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/config/setup.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
136
|
+
*
|
|
137
|
+
* @param options Optional configuration paths for schema and output files
|
|
138
|
+
* @param internalOptions Optional configuration for internal testing hooks
|
|
139
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
140
|
+
*/
|
|
141
|
+
declare function setupArkEnv(options?: ArkEnvConfigOptions, internalOptions?: {
|
|
142
|
+
_jitiAliases?: Record<string, string>;
|
|
143
|
+
}): void;
|
|
144
|
+
/**
|
|
145
|
+
* Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.
|
|
146
|
+
*
|
|
147
|
+
* @param nextConfig The Next.js configuration object or function
|
|
148
|
+
* @param options Optional configuration paths for schema and output files
|
|
149
|
+
* @returns The Next.js configuration object unchanged
|
|
150
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
151
|
+
*/
|
|
152
|
+
declare function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
153
|
+
//#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-BFQlm61W.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BFQlm61W.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":";;;;;;KAcKM,QAAAA;;;;;;KAMAC,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;;;;;AAIvF;;;;KCDD,mBAAA;EDQFN;;;;;;;;;;;;;ECMT,UAAA;;;AAdD;;;;;;;;;;;EA6BC,UAAA;EAsDA;;;;;;;AC/DD;EDmBC,MAAA;ECdkB;;;;;;;;;;ED8BlB,QAAA;EC9BA;;;;;EDqCA,QAAA;EEuDe;;;;;EFhDf,OAAA;EEkDA;;;;;EF3CA,MAAA,GAAS,MAAA;;AGtCV;;;;EH6CC,QAAA,GAAW,QAAA;AAAA;;;;;ADtFwF;;;;;AAIvF;;iBEmBG,UAAA,CACf,UAAA,UACA,UAAA,UACA,YAAA,GAAe,mBAAA,YACf,aAAA,YACA,UAAA,GAAa,IAAA,CAAK,mBAAA;;;;;;AF5BiF;;;iBGwHpF,WAAA,CAAY,OAAA;EAC3B,UAAA;EACA,UAAA;EACA,QAAA;AAAA;;;;;AH3HmG;;;;;iBIyCpF,WAAA,CACf,OAAA,GAAU,mBAAA,EACV,eAAA;EAAoB,YAAA,GAAe,MAAA;AAAA;;;;;;;;;iBAqIpB,UAAA,GAAA,CAAc,UAAA,EAAY,CAAA,EAAG,OAAA,GAAU,mBAAA,GAAsB,CAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { extractClientKeys, extractSharedKeys } from "@arkenv/build";
|
|
2
|
+
|
|
3
|
+
//#region ../internal/log/dist/index.d.ts
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/** Supported log level thresholds, from most to least verbose. */
|
|
7
|
+
type LogLevel = "debug" | "info" | "warn" | "error" | "silent";
|
|
8
|
+
/**
|
|
9
|
+
* Shared logger interface for ArkEnv packages.
|
|
10
|
+
*
|
|
11
|
+
* CLI-specific features (spinners, JSON reporters, `flush`) stay outside this type.
|
|
12
|
+
*/
|
|
13
|
+
type Logger = {
|
|
14
|
+
debug: (message: string, ...optionalParams: unknown[]) => void;
|
|
15
|
+
info: (message: string, ...optionalParams: unknown[]) => void;
|
|
16
|
+
warn: (message: string, ...optionalParams: unknown[]) => void;
|
|
17
|
+
error: (message: string, ...optionalParams: unknown[]) => void;
|
|
18
|
+
};
|
|
19
|
+
/** Programmatic logger configuration. Takes precedence over `ARKENV_LOG_LEVEL`. */
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/config/types.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Configuration options for the ArkEnv Next.js integration.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const configOptions: ArkEnvConfigOptions = {
|
|
28
|
+
* schemaPath: "./src/env.ts",
|
|
29
|
+
* outputPath: "./src/generated/env.gen.ts"
|
|
30
|
+
* };
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
type ArkEnvConfigOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Specify the path to the schema definition file.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to searching for `"src/env.ts"` or `"env.ts"` in the project root.
|
|
38
|
+
*
|
|
39
|
+
* @default "src/env.ts"
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* export default withArkEnv(nextConfig, {
|
|
43
|
+
* schemaPath: "./src/env.ts"
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
schemaPath?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Specify the path where the generated file (`env.gen.ts`) should be written.
|
|
50
|
+
*
|
|
51
|
+
* Defaults to `"generated/env.gen.ts"` in the same directory as the schema file.
|
|
52
|
+
*
|
|
53
|
+
* @default "[schemaDirectory]/generated/env.gen.ts"
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* export default withArkEnv(nextConfig, {
|
|
57
|
+
* outputPath: "./src/generated/env.gen.ts"
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
outputPath?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Specify the configuration layout.
|
|
64
|
+
*
|
|
65
|
+
* - `"flat"` (default): A single `env.ts` schema file.
|
|
66
|
+
* - `"strict"`: A split schema layout (`env/client.ts`, `env/server.ts`, and optionally `env/internal/shared.ts`).
|
|
67
|
+
*
|
|
68
|
+
* @default "flat"
|
|
69
|
+
*/
|
|
70
|
+
layout?: "flat" | "strict" /** @deprecated Use `"flat"` instead. `"simple"` will be removed in the next major version. */ | "simple";
|
|
71
|
+
/**
|
|
72
|
+
* Force standard mode code generation.
|
|
73
|
+
*
|
|
74
|
+
* When `true`, the generated `env.gen.ts` imports from `@arkenv/nextjs/standard/*`
|
|
75
|
+
* instead of `@arkenv/nextjs/*`, ensuring the Standard Schema engine (`@arkenv/standard`)
|
|
76
|
+
* is used and `arktype` is never bundled. This is set automatically when importing from
|
|
77
|
+
* `@arkenv/nextjs/standard/config`, but can be toggled manually for custom setups.
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
standard?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Enable or disable build-time environment variable validation during build/dev startup.
|
|
84
|
+
*
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
validate?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Enable or disable automatic code generation of the `env.gen.ts` file.
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
codegen?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Custom logger instance for build-time messages.
|
|
96
|
+
*
|
|
97
|
+
* When omitted, ArkEnv uses a console logger respecting `ARKENV_LOG_LEVEL`.
|
|
98
|
+
*/
|
|
99
|
+
logger?: Logger;
|
|
100
|
+
/**
|
|
101
|
+
* Minimum log level for build-time messages.
|
|
102
|
+
*
|
|
103
|
+
* Programmatic `logger` takes precedence over `logLevel`.
|
|
104
|
+
*/
|
|
105
|
+
logLevel?: LogLevel;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/config/codegen.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* Run code generation to read the schema file and generate the env.gen.ts factory.
|
|
111
|
+
*
|
|
112
|
+
* @param schemaPath The absolute path to the schema file or directory
|
|
113
|
+
* @param outputPath The absolute path to the generated output file
|
|
114
|
+
* @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted
|
|
115
|
+
* @param forceStandard Force standard mode code generation
|
|
116
|
+
* @throws An error if strict layout files are missing when `layoutOption` is `"strict"`
|
|
117
|
+
*/
|
|
118
|
+
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: ArkEnvConfigOptions["layout"], forceStandard?: boolean, logOptions?: Pick<ArkEnvConfigOptions, "logger" | "logLevel">): void;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/config/extract.d.ts
|
|
121
|
+
/**
|
|
122
|
+
* Statically extract client and shared keys from the schema content.
|
|
123
|
+
*
|
|
124
|
+
* @param content The schema file string content
|
|
125
|
+
* @returns An object containing the extracted client and shared keys
|
|
126
|
+
*/
|
|
127
|
+
declare function extractKeys(content: string): {
|
|
128
|
+
clientKeys: string[];
|
|
129
|
+
sharedKeys: string[];
|
|
130
|
+
isLegacy?: boolean;
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/config/setup.d.ts
|
|
134
|
+
/**
|
|
135
|
+
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
136
|
+
*
|
|
137
|
+
* @param options Optional configuration paths for schema and output files
|
|
138
|
+
* @param internalOptions Optional configuration for internal testing hooks
|
|
139
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
140
|
+
*/
|
|
141
|
+
declare function setupArkEnv(options?: ArkEnvConfigOptions, internalOptions?: {
|
|
142
|
+
_jitiAliases?: Record<string, string>;
|
|
143
|
+
}): void;
|
|
144
|
+
/**
|
|
145
|
+
* Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.
|
|
146
|
+
*
|
|
147
|
+
* @param nextConfig The Next.js configuration object or function
|
|
148
|
+
* @param options Optional configuration paths for schema and output files
|
|
149
|
+
* @returns The Next.js configuration object unchanged
|
|
150
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
151
|
+
*/
|
|
152
|
+
declare function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
153
|
+
//#endregion
|
|
154
|
+
export { extractKeys as a, withArkEnv as i, extractSharedKeys as n, runCodegen as o, setupArkEnv as r, ArkEnvConfigOptions as s, extractClientKeys as t };
|
|
155
|
+
//# sourceMappingURL=index-CNzwVE5N.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CNzwVE5N.d.cts","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":";;;;;;KAcKM,QAAAA;;;;;;KAMAC,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;;;;;AAIvF;;;;KCDD,mBAAA;EDQFN;;;;;;;;;;;;;ECMT,UAAA;;;AAdD;;;;;;;;;;;EA6BC,UAAA;EAsDA;;;;;;;AC/DD;EDmBC,MAAA;ECdkB;;;;;;;;;;ED8BlB,QAAA;EC9BA;;;;;EDqCA,QAAA;EEuDe;;;;;EFhDf,OAAA;EEkDA;;;;;EF3CA,MAAA,GAAS,MAAA;;AGtCV;;;;EH6CC,QAAA,GAAW,QAAA;AAAA;;;;;ADtFwF;;;;;AAIvF;;iBEmBG,UAAA,CACf,UAAA,UACA,UAAA,UACA,YAAA,GAAe,mBAAA,YACf,aAAA,YACA,UAAA,GAAa,IAAA,CAAK,mBAAA;;;;;;AF5BiF;;;iBGwHpF,WAAA,CAAY,OAAA;EAC3B,UAAA;EACA,UAAA;EACA,QAAA;AAAA;;;;;AH3HmG;;;;;iBIyCpF,WAAA,CACf,OAAA,GAAU,mBAAA,EACV,eAAA;EAAoB,YAAA,GAAe,MAAA;AAAA;;;;;;;;;iBAqIpB,UAAA,GAAA,CAAc,UAAA,EAAY,CAAA,EAAG,OAAA,GAAU,mBAAA,GAAsB,CAAA"}
|
|
@@ -83,6 +83,9 @@ declare const $: _$arktype.Scope<{
|
|
|
83
83
|
}>;
|
|
84
84
|
type $ = (typeof $)["t"]; //#endregion
|
|
85
85
|
//#endregion
|
|
86
|
+
//#region ../internal/types/dist/helpers.d.ts
|
|
87
|
+
type Dict<T> = Record<string, T | undefined>;
|
|
88
|
+
//#endregion
|
|
86
89
|
//#region ../internal/types/dist/standard-schema.d.ts
|
|
87
90
|
/**
|
|
88
91
|
* @see https://github.com/standard-schema/standard-schema/tree/3130ce43fdd848d9ab49dbb0458d04f18459961c/packages/spec
|
|
@@ -176,12 +179,12 @@ declare namespace StandardSchemaV1 {
|
|
|
176
179
|
*
|
|
177
180
|
* @template T - The schema definition to infer from
|
|
178
181
|
*/
|
|
179
|
-
type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value:
|
|
182
|
+
type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Output : T extends ((value: Dict<string>) => infer R) ? R extends type.errors ? never : R : T extends {
|
|
180
183
|
t: infer U;
|
|
181
184
|
} ? U : T extends type.Any<infer U, infer _Scope> ? U : never;
|
|
182
185
|
//#endregion
|
|
183
186
|
//#region ../internal/types/dist/schema.d.ts
|
|
184
187
|
type SchemaShape = Record<string, unknown>;
|
|
185
188
|
//#endregion
|
|
186
|
-
export { InferType as n,
|
|
187
|
-
//# sourceMappingURL=index-
|
|
189
|
+
export { $ as a, Dict as i, InferType as n, StandardSchemaV1 as r, SchemaShape as t };
|
|
190
|
+
//# sourceMappingURL=index-bjEZwPUt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-bjEZwPUt.d.ts","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,KAAAA;EACzBC,MAAAA,EAAQlB,SAAAA,CAAUM,SAAAA;IAChBF,IAAAA,EAAMJ,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCG,IAAAA,CAAKD,CAAAA;MACpE,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEE,SAAAA,EAAWP,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCM,SAAAA,CAAUJ,CAAAA;MAC9E,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEe,IAAAA;IACAC,KAAAA;IACAC,YAAAA;IACAC,GAAAA;IACAC,MAAAA,EAAQxB,SAAAA,CAAUM,SAAAA;M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DKoD,WAAAA,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,CAAYT,MAAAA;AAAAA;;;;;;AF9EC;;;;;;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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`./config-CStvXoN3.cjs`);const e=require(`./arkenv-internal-Cll5pV_F.cjs`),t=require(`./script-D-MYC2Uf.cjs`);let n=require(`@arkenv/core`);function r(t,r){return t&&typeof t==`object`&&(`runtimeEnv`in t||`server`in t||`client`in t||`shared`in t)?e.t(t,!1,void 0,n.arkenv,n.getSchemaKeys):e.t(t,r,{isServer:!1},n.arkenv,n.getSchemaKeys)}exports.ArkEnvScript=t.t,exports.arkenv=r,exports.default=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["arkenvInternal","coreArkenv","getSchemaKeys"],"sources":["../src/index.ts"],"sourcesContent":["import type { EnvSchema, Infer } from \"@arkenv/core\";\nimport { arkenv as coreArkenv, getSchemaKeys } from \"@arkenv/core\";\nimport type { $ } from \"@repo/scope\";\nimport type { SchemaShape } from \"@repo/types\";\nimport type { type as at, distill } from \"arktype\";\nimport { arkenvInternal } from \"./arkenv-internal\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Extract keys from a schema type that are visible on the client:\n * - Keys prefixed with `NEXT_PUBLIC_`\n * - `NODE_ENV` (implicitly shared by Next.js)\n * - Keys listed in `exposeToClient`\n */\ntype ClientVisibleKeys<\n\tTSchema extends SchemaShape,\n\tTExpose extends keyof TSchema,\n> = {\n\t[K in keyof TSchema]: K extends `NEXT_PUBLIC_${string}`\n\t\t? K\n\t\t: K extends \"NODE_ENV\"\n\t\t\t? K\n\t\t\t: K extends TExpose\n\t\t\t\t? K\n\t\t\t\t: never;\n}[keyof TSchema];\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).\n */\nexport function arkenv<\n\tconst TSchema extends SchemaShape & { runtimeEnv?: never } = {},\n\tconst TExpose extends keyof TSchema = never,\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<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\t/** @deprecated Use `exposeToClient` instead */\n\t\texpose?: readonly TExpose[];\n\t\t/** @deprecated Use `exposeToClient` instead */\n\t\tshared?: readonly TExpose[];\n\t\textends?: [...TExtends];\n\t\truntimeEnv?: Record<string, unknown>;\n\t},\n): Readonly<\n\tPick<\n\t\tdistill.Out<at.infer<TSchema, $>>,\n\t\tExtract<\n\t\t\tkeyof distill.Out<at.infer<TSchema, $>>,\n\t\t\tClientVisibleKeys<TSchema, TExpose>\n\t\t>\n\t> &\n\t\tMergeExtends<TExtends>\n>;\n\n/**\n * @deprecated Use the unified flat layout signature instead: `arkenv(schema, options)`\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\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\"client\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\treturn arkenvInternal(\n\t\t\tschemaOrOptions,\n\t\t\tfalse,\n\t\t\tundefined,\n\t\t\tcoreArkenv,\n\t\t\tgetSchemaKeys,\n\t\t);\n\t}\n\n\treturn arkenvInternal(\n\t\tschemaOrOptions,\n\t\toptionsOrIsServer,\n\t\t{ isServer: false },\n\t\tcoreArkenv,\n\t\tgetSchemaKeys,\n\t);\n}\n\nexport type { ArkEnvScriptProps } from \"./script\";\nexport { ArkEnvScript } from \"./script\";\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":"mPA8EA,SAAgB,EAAO,EAAsB,EAA8B,CAmB1E,OAjBC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GACZ,WAAY,GAGNA,EAAAA,EACN,EACA,GACA,IAAA,GACAC,EAAAA,OACAC,EAAAA,cACA,CAGKF,EAAAA,EACN,EACA,EACA,CAAE,SAAU,GAAO,CACnBC,EAAAA,OACAC,EAAAA,cACA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,27 +1,43 @@
|
|
|
1
|
-
import { t as SchemaShape } from "./index-
|
|
2
|
-
import {
|
|
1
|
+
import { a as $, t as SchemaShape } from "./index-96RGPyfa.cjs";
|
|
2
|
+
import { t as MergeExtends } from "./types-44R9mgTa.cjs";
|
|
3
|
+
import { n as ArkEnvScriptProps, t as ArkEnvScript } from "./script-BHFJ0MU_.cjs";
|
|
4
|
+
import { EnvSchema, Infer } from "@arkenv/core";
|
|
5
|
+
import { distill, type } from "arktype";
|
|
3
6
|
|
|
4
7
|
//#region src/index.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Extract keys from a schema type that are visible on the client:
|
|
10
|
+
* - Keys prefixed with `NEXT_PUBLIC_`
|
|
11
|
+
* - `NODE_ENV` (implicitly shared by Next.js)
|
|
12
|
+
* - Keys listed in `exposeToClient`
|
|
13
|
+
*/
|
|
14
|
+
type ClientVisibleKeys<TSchema extends SchemaShape, TExpose extends keyof TSchema> = { [K in keyof TSchema]: K extends `NEXT_PUBLIC_${string}` ? K : K extends "NODE_ENV" ? K : K extends TExpose ? K : never }[keyof TSchema];
|
|
5
15
|
/**
|
|
6
16
|
* Create a validated, type-safe environment configuration for Next.js applications (Client-side / SSR entry point).
|
|
7
|
-
*
|
|
8
|
-
* @param options The environment validation configuration options
|
|
9
|
-
* @returns A validated, readonly environment variables object wrapped in a security proxy
|
|
10
|
-
* @throws An error if any client-side variable is not prefixed with `NEXT_PUBLIC_`
|
|
11
|
-
* @throws An error if any client or shared variable is missing from `runtimeEnv`
|
|
12
17
|
*/
|
|
13
|
-
declare function
|
|
18
|
+
declare function arkenv<const TSchema extends SchemaShape & {
|
|
19
|
+
runtimeEnv?: never;
|
|
20
|
+
} = {}, const TExpose extends keyof TSchema = never, const TExtends extends readonly unknown[] = []>(schema: EnvSchema<TSchema>, options?: {
|
|
21
|
+
/**
|
|
22
|
+
* Custom environment variables to expose to the client bundle.
|
|
23
|
+
* By default, variables prefixed with `NEXT_PUBLIC_` and `NODE_ENV` are exposed automatically.
|
|
24
|
+
* Use this option to expose custom variables that do not have the `NEXT_PUBLIC_` prefix.
|
|
25
|
+
*/
|
|
26
|
+
exposeToClient?: readonly TExpose[]; /** @deprecated Use `exposeToClient` instead */
|
|
27
|
+
expose?: readonly TExpose[]; /** @deprecated Use `exposeToClient` instead */
|
|
28
|
+
shared?: readonly TExpose[];
|
|
29
|
+
extends?: [...TExtends];
|
|
30
|
+
runtimeEnv?: Record<string, unknown>;
|
|
31
|
+
}): Readonly<Pick<distill.Out<type.infer<TSchema, $>>, Extract<keyof distill.Out<type.infer<TSchema, $>>, ClientVisibleKeys<TSchema, TExpose>>> & MergeExtends<TExtends>>;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use the unified flat layout signature instead: `arkenv(schema, options)`
|
|
34
|
+
*/
|
|
35
|
+
declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
|
|
14
36
|
server?: EnvSchema<TServer>;
|
|
15
37
|
client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
|
|
16
38
|
shared?: EnvSchema<TShared>;
|
|
17
39
|
runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
|
|
18
|
-
}): Readonly<Infer
|
|
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;
|
|
40
|
+
}): Readonly<Infer<TServer & TClient & TShared>>;
|
|
25
41
|
//#endregion
|
|
26
|
-
export { type
|
|
42
|
+
export { ArkEnvScript, type ArkEnvScriptProps, arkenv, arkenv as default };
|
|
27
43
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;AAM4C;;;;KAQvC,iBAAA,iBACY,WAAA,wBACM,OAAA,kBAEV,OAAA,GAAU,CAAA,mCACnB,CAAA,GACA,CAAA,sBACC,CAAA,GACA,CAAA,SAAU,OAAA,GACT,CAAA,iBAEE,OAAA;;;;iBAKQ,MAAA,uBACO,WAAA;EAAgB,UAAA;AAAA,oCACV,OAAA,yDAAA,CAG5B,MAAA,EAAQ,SAAA,CAAU,OAAA,GAClB,OAAA;EAXO;;;;;EAiBN,cAAA,YAA0B,OAAA,IA1BL;EA4BrB,MAAA,YAAkB,OAAA,IA1BP;EA4BX,MAAA,YAAkB,OAAA;EAClB,OAAA,OAAc,QAAA;EACd,UAAA,GAAa,MAAA;AAAA,IAEZ,QAAA,CACF,IAAA,CACC,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,IAC9B,OAAA,OACO,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,IACpC,iBAAA,CAAkB,OAAA,EAAS,OAAA,MAG5B,YAAA,CAAa,QAAA;;;;iBAMC,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,KAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
|