@arkenv/nextjs 1.0.0-alpha.3 → 1.0.0-alpha.5
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/dist/arkenv-internal-Do5bRP26.js +2 -0
- package/dist/arkenv-internal-Do5bRP26.js.map +1 -0
- package/dist/arkenv-internal-Dz0mDRKT.cjs +2 -0
- package/dist/arkenv-internal-Dz0mDRKT.cjs.map +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -3
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +6 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/config-DNJIS9zz.cjs +103 -0
- package/dist/config-DNJIS9zz.cjs.map +1 -0
- package/dist/config.cjs +1 -76
- package/dist/config.d.cts +41 -29
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.ts +41 -29
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +66 -39
- package/dist/config.js.map +1 -1
- package/dist/{index-DvODqC0J.d.ts → index-96RGPyfa.d.cts} +2 -2
- package/dist/{index-CRUkF6-E.d.cts.map → index-96RGPyfa.d.cts.map} +1 -1
- package/dist/{index-CRUkF6-E.d.cts → index-Dypl5Zzg.d.ts} +2 -2
- package/dist/{index-DvODqC0J.d.ts.map → index-Dypl5Zzg.d.ts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +30 -8
- 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 +23 -8
- package/dist/react-server.d.cts.map +1 -1
- package/dist/react-server.d.ts +23 -8
- 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-CUpLLTKJ.cjs +2 -0
- package/dist/script-CUpLLTKJ.cjs.map +1 -0
- package/dist/script-DB7wIIvT.js +2 -0
- package/dist/script-DB7wIIvT.js.map +1 -0
- package/dist/script-DSWuhk88.d.cts +21 -0
- package/dist/script-DSWuhk88.d.cts.map +1 -0
- package/dist/script-Ii42Y-xZ.d.ts +21 -0
- package/dist/script-Ii42Y-xZ.d.ts.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +6 -3
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +6 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/shared.cjs +1 -1
- package/dist/shared.cjs.map +1 -1
- package/dist/shared.d.cts +3 -3
- package/dist/shared.d.cts.map +1 -1
- package/dist/shared.d.ts +3 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +1 -1
- package/dist/shared.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-BTG7L0mq.d.cts → types-44R9mgTa.d.cts} +2 -2
- package/dist/{types-BTG7L0mq.d.cts.map → types-44R9mgTa.d.cts.map} +1 -1
- package/dist/{types-8YUW70UX.d.ts → types-gP-eTDyz.d.ts} +2 -2
- package/dist/{types-8YUW70UX.d.ts.map → types-gP-eTDyz.d.ts.map} +1 -1
- package/package.json +54 -9
- package/dist/arkenv-internal-BI25fuIK.cjs +0 -2
- package/dist/arkenv-internal-BI25fuIK.cjs.map +0 -1
- package/dist/arkenv-internal-DOhvmOZ_.js +0 -2
- package/dist/arkenv-internal-DOhvmOZ_.js.map +0 -1
- package/dist/config.cjs.map +0 -1
package/dist/config.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { extractClientKeys, extractSharedKeys } from "@arkenv/build";
|
|
2
2
|
|
|
3
3
|
//#region src/config.d.ts
|
|
4
|
-
declare global {
|
|
5
|
-
var __arkenv_watcher__: _$chokidar.FSWatcher | undefined;
|
|
6
|
-
}
|
|
7
4
|
/**
|
|
8
5
|
* Configuration options for the ArkEnv Next.js integration.
|
|
9
6
|
*
|
|
@@ -47,13 +44,46 @@ type ArkEnvConfigOptions = {
|
|
|
47
44
|
/**
|
|
48
45
|
* Specify the configuration layout.
|
|
49
46
|
*
|
|
50
|
-
* - `"
|
|
47
|
+
* - `"flat"` (default): A single `env.ts` schema file.
|
|
51
48
|
* - `"strict"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).
|
|
52
49
|
*
|
|
53
|
-
* @default "
|
|
50
|
+
* @default "flat"
|
|
54
51
|
*/
|
|
55
|
-
layout?: "
|
|
52
|
+
layout?: "flat" | "strict" /** @deprecated Use `"flat"` instead. `"simple"` will be removed in the next major version. */ | "simple";
|
|
53
|
+
/**
|
|
54
|
+
* Force standard mode code generation.
|
|
55
|
+
*
|
|
56
|
+
* When `true`, the generated `env.gen.ts` imports from `@arkenv/nextjs/standard/*`
|
|
57
|
+
* instead of `@arkenv/nextjs/*`, ensuring the Standard Schema engine (`@arkenv/standard`)
|
|
58
|
+
* is used and `arktype` is never bundled. This is set automatically when importing from
|
|
59
|
+
* `@arkenv/nextjs/standard/config`, but can be toggled manually for custom setups.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
standard?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Enable or disable build-time environment variable validation during build/dev startup.
|
|
66
|
+
*
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
validate?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Enable or disable automatic code generation of the `env.gen.ts` file.
|
|
72
|
+
*
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
codegen?: boolean;
|
|
56
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
79
|
+
*
|
|
80
|
+
* @param options Optional configuration paths for schema and output files
|
|
81
|
+
* @param internalOptions Optional configuration for internal testing hooks
|
|
82
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
83
|
+
*/
|
|
84
|
+
declare function setupArkEnv(options?: ArkEnvConfigOptions, internalOptions?: {
|
|
85
|
+
_jitiAliases?: Record<string, string>;
|
|
86
|
+
}): void;
|
|
57
87
|
/**
|
|
58
88
|
* Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.
|
|
59
89
|
*
|
|
@@ -69,9 +99,10 @@ declare function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
|
69
99
|
* @param schemaPath The absolute path to the schema file or directory
|
|
70
100
|
* @param outputPath The absolute path to the generated output file
|
|
71
101
|
* @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted
|
|
102
|
+
* @param forceStandard Force standard mode code generation
|
|
72
103
|
* @throws An error if strict layout files are missing when `layoutOption` is `"strict"`
|
|
73
104
|
*/
|
|
74
|
-
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: "
|
|
105
|
+
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: ArkEnvConfigOptions["layout"], forceStandard?: boolean): void;
|
|
75
106
|
/**
|
|
76
107
|
* Statically extract client and shared keys from the schema content.
|
|
77
108
|
*
|
|
@@ -81,27 +112,8 @@ declare function runCodegen(schemaPath: string, outputPath: string, layoutOption
|
|
|
81
112
|
declare function extractKeys(content: string): {
|
|
82
113
|
clientKeys: string[];
|
|
83
114
|
sharedKeys: string[];
|
|
115
|
+
isLegacy?: boolean;
|
|
84
116
|
};
|
|
85
|
-
/**
|
|
86
|
-
* Extract env var keys from a strict-layout `client.ts` file.
|
|
87
|
-
*
|
|
88
|
-
* Locates the first `arkenv({...})` call and delegates to `parseBlockKeys`
|
|
89
|
-
* to enumerate the keys defined in the schema object.
|
|
90
|
-
*
|
|
91
|
-
* @param content The source text of `client.ts`
|
|
92
|
-
* @returns An array of env var key names found in the client schema
|
|
93
|
-
*/
|
|
94
|
-
declare function extractClientKeys(content: string): string[];
|
|
95
|
-
/**
|
|
96
|
-
* Extract env var keys from a strict-layout `internal/shared.ts` file.
|
|
97
|
-
*
|
|
98
|
-
* Locates the `SharedSchema = ...({...})` assignment and delegates to
|
|
99
|
-
* `parseBlockKeys` to enumerate the keys defined in the schema object.
|
|
100
|
-
*
|
|
101
|
-
* @param content The source text of `internal/shared.ts`
|
|
102
|
-
* @returns An array of env var key names found in the shared schema
|
|
103
|
-
*/
|
|
104
|
-
declare function extractSharedKeys(content: string): string[];
|
|
105
117
|
//#endregion
|
|
106
|
-
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, withArkEnv };
|
|
118
|
+
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, setupArkEnv, withArkEnv };
|
|
107
119
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;AA+CA;;;;;;;;;;KAAY,mBAAA;EAqEJ;AAUR;;;;;;;;;;;AAuIA;EAxMC,UAAA;EAwMyB;;;;;;;;;;;;;EAzLzB,UAAA;EAuMe;;;;;;;;EA7Lf,MAAA,qBAiMuB;EA6LR;;;;;;;;;;EA9Wf,QAAA;;;;;;EAOA,QAAA;;;;;;EAOA,OAAA;AAAA;;;;;;;;iBAUe,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;;;;;;;;;;iBAc7D,UAAA,CACf,UAAA,UACA,UAAA,UACA,YAAA,GAAe,mBAAA,YACf,aAAA;;;;;;;iBA6Le,WAAA,CAAY,OAAA;EAC3B,UAAA;EACA,UAAA;EACA,QAAA;AAAA"}
|
package/dist/config.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import e from"node:fs";import t from"node:path";import{
|
|
2
|
-
`||
|
|
3
|
-
`||
|
|
4
|
-
|
|
5
|
-
// prettier-ignore
|
|
1
|
+
import e from"node:fs";import t from"node:path";import{fileURLToPath as n}from"node:url";import{extractBlock as r,extractClientKeys as i,extractSharedKeys as a,findSchemaPath as o,parseBlockKeys as s,resolveLayout as c,watchSchema as l}from"@arkenv/build";import{createJiti as u}from"jiti";let d=!1;function f(e){return e===`simple`?(process.env.NODE_ENV===`development`&&!d&&(d=!0,console.warn(`⚠️ [arkenv] The 'simple' layout option is deprecated and will be removed in the next major version. Use 'flat' instead.`)),`simple`):e===`flat`?`simple`:e}function p(r,i){let a=r?.schemaPath?t.resolve(r.schemaPath):o(),s=!1;if(a)if(e.existsSync(a))s=!0;else{let n=t.extname(a);if(n){let t=a.slice(0,-n.length);e.existsSync(t)&&(s=!0)}}if(!a||!s)throw Error(`[ArkEnv] Could not find schema file at ${r?.schemaPath||`src/env.ts or env.ts`}. Please specify 'schemaPath' in setupArkEnv options.`);let{layout:d,baseDir:p}=c(a,f(r?.layout)),m=d===`strict`&&p?p:t.dirname(a),g=t.join(m,`generated`,`env.gen.ts`),_=r?.outputPath?t.resolve(r.outputPath):g,v=r?.codegen??!0;if(v)try{h(a,_,d,r?.standard)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`[ArkEnv] Failed to generate env.gen.ts: ${t}`)}if(r?.validate??!0)try{globalThis.__arkenv_force_server__=!0;let r=d===`strict`&&p?t.join(p,`server.ts`):a,o=typeof __filename<`u`?__filename:import.meta.url?n(import.meta.url):``,s=t.dirname(o),c=e.existsSync(t.join(s,`shared.ts`))?t.join(s,`shared.ts`):t.join(s,`shared.js`);u(r,{moduleCache:!1,fsCache:!1,tsconfigPaths:!0,alias:{"server-only":c,"./script":c,"./script.tsx":c,...i?._jitiAliases}})(r)}catch(e){console.error(`
|
|
2
|
+
❌ [ArkEnv] Environment validation failed:`),console.error(e instanceof Error?e.message:String(e)),console.error(``),process.exit(1)}finally{delete globalThis.__arkenv_force_server__}(process.env.NODE_ENV===`development`||process.env.NEXT_PHASE===`phase-development-server`)&&v&&l(d===`strict`&&p?[t.join(p,`internal`,`shared.ts`),t.join(p,`client.ts`),t.join(p,`server.ts`)].filter(e.existsSync):[a],()=>{h(a,_,d,r?.standard)})}function m(e,t){return p(t),e}function h(n,r,o,s){let{layout:l,baseDir:u}=c(n,f(o)),d=``;if(l===`strict`){let n=t.join(u,`client.ts`),r=t.join(u,`internal`,`shared.ts`),o=e.existsSync(n)?e.readFileSync(n,`utf-8`):``,c=e.existsSync(r)?e.readFileSync(r,`utf-8`):``,l=!!s||o.includes(`@arkenv/standard`)||o.includes(`arkenv/standard`)||c.includes(`@arkenv/standard`)||c.includes(`arkenv/standard`);d=C(i(o),a(c),l)}else{let t=e.readFileSync(n,`utf-8`),r=!!s||t.includes(`@arkenv/standard`)||t.includes(`arkenv/standard`),{clientKeys:i,sharedKeys:a,isLegacy:o}=_(t);d=o?x(i,a,r):S(i,a,r)}let p=t.dirname(r);e.existsSync(p)||e.mkdirSync(p,{recursive:!0});let m=!0;e.existsSync(r)&&e.readFileSync(r,`utf-8`)===d&&(m=!1),m&&e.writeFileSync(r,d,`utf-8`)}function g(e){let t=/\b(?:arkenv|createEnv)\s*\(/g;for(;t.exec(e)!==null;){let n=1,r=t.lastIndex,i=null,a=null,o=0,s=0,c=[],l=``;for(;r<e.length&&n>0;){let t=e[r],u=e[r+1];if(a===`single`){(t===`
|
|
3
|
+
`||t===`\r`)&&(a=null),l+=t,r++;continue}if(a===`multi`){if(t===`*`&&u===`/`){a=null,l+=`*/`,r+=2;continue}l+=t,r++;continue}if(i){t===i&&e[r-1]!==`\\`&&(i=null),l+=t,r++;continue}if(t===`/`&&u===`/`){a=`single`,l+=`//`,r+=2;continue}if(t===`/`&&u===`*`){a=`multi`,l+=`/*`,r+=2;continue}if(t===`'`||t===`"`||t==="`"){i=t,l+=t,r++;continue}if(t===`(`?n++:t===`)`?n--:t===`{`?o++:t===`}`?o--:t===`[`?s++:t===`]`&&s--,n===0){c.push(l);break}t===`,`&&n===1&&o===0&&s===0?(c.push(l),l=``):l+=t,r++}if(n===0&&c.length>0)return{schemaArg:c[0].trim(),optionsArg:c[1]?c[1].trim():null}}return null}function _(e){let t=[],n=[],i=g(e);if(!i)return{clientKeys:t,sharedKeys:n,isLegacy:!1};let a=s(i.schemaArg.replace(/^\{/,``).replace(/\}$/,``).trim()),o=a.includes(`client`)||a.includes(`server`)||a.includes(`shared`);if(o){let e=r(i.schemaArg,`client`);e&&t.push(...s(e));let a=r(i.schemaArg,`shared`);a&&n.push(...s(a))}else{let e=[];if(i.optionsArg){let t=i.optionsArg.match(/exposeToClient\s*:\s*\[([\s\S]*?)\]/)||i.optionsArg.match(/expose\s*:\s*\[([\s\S]*?)\]/)||i.optionsArg.match(/shared\s*:\s*\[([\s\S]*?)\]/);if(t){let n=t[1].matchAll(/['"`](.*?)['"`]/g);for(let t of n)e.push(t[1])}}for(let r of a)e.includes(r)||r===`NODE_ENV`?n.push(r):r.startsWith(`NEXT_PUBLIC_`)&&t.push(r)}return{clientKeys:t,sharedKeys:n,isLegacy:o}}function v(e,t){return Array.from(new Set([...e,...t])).map(e=>`\t\t\t${e}: typeof window !== "undefined" ? (globalThis as any).__arkenv_env__?.${e} ?? process.env.${e} : process.env.${e},`).join(`
|
|
4
|
+
`)}const y=`/* eslint-disable */
|
|
6
5
|
// biome-ignore format: auto-generated
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { arkenv as coreArkenv } from "@arkenv/nextjs";
|
|
14
|
-
import type { Infer } from "@arkenv/nextjs";
|
|
15
|
-
|
|
6
|
+
// Generated by ArkEnv. DO NOT EDIT DIRECTLY.
|
|
7
|
+
`,b=`
|
|
8
|
+
export default arkenv;
|
|
9
|
+
`;function x(e,t,n){let r=v(e,t);return`${y}
|
|
10
|
+
import { arkenv as coreArkenv } from "${n?`@arkenv/nextjs/standard`:`@arkenv/nextjs`}";
|
|
11
|
+
${n?``:`
|
|
16
12
|
export { type } from "@arkenv/nextjs";
|
|
17
|
-
|
|
13
|
+
`}
|
|
18
14
|
export function arkenv<
|
|
19
15
|
const TServer extends Record<string, any> = {},
|
|
20
16
|
const TClient extends Record<string, any> = {},
|
|
@@ -25,29 +21,65 @@ export function arkenv<
|
|
|
25
21
|
[K in keyof TClient]: K extends \`NEXT_PUBLIC_\${string}\` ? unknown : never;
|
|
26
22
|
};
|
|
27
23
|
shared?: TShared;
|
|
28
|
-
})
|
|
24
|
+
}) {
|
|
29
25
|
return coreArkenv({
|
|
30
26
|
...options,
|
|
31
27
|
runtimeEnv: {
|
|
32
|
-
${
|
|
33
|
-
`)}
|
|
28
|
+
${r}
|
|
34
29
|
},
|
|
35
30
|
} as any) as any;
|
|
36
31
|
}
|
|
32
|
+
${b}`}function S(e,t,n){let r=v(e,t);return`${y}
|
|
33
|
+
import { arkenv as coreArkenv } from "${n?`@arkenv/nextjs/standard`:`@arkenv/nextjs`}";${n?``:`
|
|
34
|
+
import type { type as at, distill } from "arktype";`}
|
|
35
|
+
${n?``:`
|
|
36
|
+
export { type } from "@arkenv/nextjs";
|
|
37
|
+
`}
|
|
38
|
+
export function arkenv<
|
|
39
|
+
const TSchema extends Record<string, unknown> & { runtimeEnv?: never } = {},
|
|
40
|
+
const TExpose extends keyof TSchema = never,
|
|
41
|
+
const TExtends extends readonly unknown[] = [],
|
|
42
|
+
>(
|
|
43
|
+
schema: TSchema,
|
|
44
|
+
options?: {
|
|
45
|
+
/**
|
|
46
|
+
* Custom environment variables to expose to the client bundle.
|
|
47
|
+
* By default, variables prefixed with \`NEXT_PUBLIC_\` and \`NODE_ENV\` are exposed automatically.
|
|
48
|
+
* Use this option to expose custom variables that do not have the \`NEXT_PUBLIC_\` prefix.
|
|
49
|
+
*/
|
|
50
|
+
exposeToClient?: readonly TExpose[];
|
|
51
|
+
extends?: [...TExtends];
|
|
52
|
+
},
|
|
53
|
+
): ${n?`Readonly<TSchema>`:`Readonly<distill.Out<at.infer<TSchema>>>`} {
|
|
54
|
+
// Types expose the full schema for a great DX on the server; the runtime
|
|
55
|
+
// Proxy from \`@arkenv/nextjs\` enforces the security boundary by throwing
|
|
56
|
+
// when a server-only variable is accessed on the client.
|
|
57
|
+
const env = coreArkenv(schema as any, {
|
|
58
|
+
...options,
|
|
59
|
+
runtimeEnv: {
|
|
60
|
+
${r}
|
|
61
|
+
},
|
|
62
|
+
} as any);
|
|
63
|
+
return env${n?``:` as unknown as Readonly<distill.Out<at.infer<TSchema>>>`};
|
|
64
|
+
}
|
|
65
|
+
${b}`}function C(e,t,n){let r=v(e,t);return`${y}
|
|
66
|
+
import { arkenv as coreArkenv } from "${n?`@arkenv/nextjs/standard/client`:`@arkenv/nextjs/client`}";${n?``:`
|
|
67
|
+
import type { Infer } from "@arkenv/core";`}
|
|
68
|
+
${n?``:`
|
|
69
|
+
export { type } from "@arkenv/nextjs/client";
|
|
70
|
+
`}
|
|
71
|
+
type ResolveExtend<T> = [Infer<T>] extends [never] ? T : Infer<T>;
|
|
37
72
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @file env.gen.ts
|
|
44
|
-
* @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.
|
|
45
|
-
* @see https://arkenv.js.org
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
import { arkenv as coreArkenv } from "@arkenv/nextjs/client";
|
|
73
|
+
type UnionToIntersection<U> = (
|
|
74
|
+
U extends any ? (k: U) => void : never
|
|
75
|
+
) extends (k: infer I) => void
|
|
76
|
+
? I
|
|
77
|
+
: never;
|
|
49
78
|
|
|
50
|
-
|
|
79
|
+
type MergeExtends<TExtends extends readonly unknown[] | undefined> =
|
|
80
|
+
TExtends extends readonly unknown[]
|
|
81
|
+
? UnionToIntersection<ResolveExtend<TExtends[number]>>
|
|
82
|
+
: {};
|
|
51
83
|
|
|
52
84
|
export function arkenv<
|
|
53
85
|
const TSchema extends Record<string, any> = {},
|
|
@@ -59,18 +91,13 @@ export function arkenv<
|
|
|
59
91
|
options?: {
|
|
60
92
|
extends?: [...TExtends];
|
|
61
93
|
},
|
|
62
|
-
) {
|
|
63
|
-
return coreArkenv
|
|
94
|
+
): ${n?`Readonly<TSchema & MergeExtends<TExtends>>`:`Readonly<Infer<TSchema> & MergeExtends<TExtends>>`} {
|
|
95
|
+
return coreArkenv(schema as any, {
|
|
64
96
|
...options,
|
|
65
97
|
runtimeEnv: {
|
|
66
|
-
${
|
|
67
|
-
`)}
|
|
98
|
+
${r}
|
|
68
99
|
},
|
|
69
100
|
} as any);
|
|
70
101
|
}
|
|
71
|
-
|
|
72
|
-
export default arkenv;
|
|
73
|
-
`}function p(e){let t=h(e);return t?u(t):[]}function m(e){let t=g(e);return t?u(t):[]}function h(e){let t=/\barkenv\s*\(\s*(?:[a-zA-Z0-9_$.]+\s*\(\s*)*\{/g;if(!t.exec(e))return null;let n=t.lastIndex,r=1,i=n,a=null,o=null;for(;i<e.length&&r>0;){let t=e[i],n=e[i+1];if(o===`single`){(t===`
|
|
74
|
-
`||t===`\r`)&&(o=null),i++;continue}if(o===`multi`){if(t===`*`&&n===`/`){o=null,i+=2;continue}i++;continue}if(a){t===a&&e[i-1]!==`\\`&&(a=null),i++;continue}if(t===`/`&&n===`/`){o=`single`,i+=2;continue}if(t===`/`&&n===`*`){o=`multi`,i+=2;continue}if(t===`'`||t===`"`||t==="`"){a=t,i++;continue}t===`{`?r++:t===`}`&&r--,i++}return r===0?e.slice(n,i-1):null}function g(e){let t=/\bSharedSchema\s*=\s*(?:[a-zA-Z0-9_$.]+\s*\(\s*)*\{/g;if(!t.exec(e))return null;let n=t.lastIndex,r=1,i=n,a=null,o=null;for(;i<e.length&&r>0;){let t=e[i],n=e[i+1];if(o===`single`){(t===`
|
|
75
|
-
`||t===`\r`)&&(o=null),i++;continue}if(o===`multi`){if(t===`*`&&n===`/`){o=null,i+=2;continue}i++;continue}if(a){t===a&&e[i-1]!==`\\`&&(a=null),i++;continue}if(t===`/`&&n===`/`){o=`single`,i+=2;continue}if(t===`/`&&n===`*`){o=`multi`,i+=2;continue}if(t===`'`||t===`"`||t==="`"){a=t,i++;continue}t===`{`?r++:t===`}`&&r--,i++}return r===0?e.slice(n,i-1):null}export{p as extractClientKeys,c as extractKeys,m as extractSharedKeys,s as runCodegen,r as withArkEnv};
|
|
102
|
+
${b}`}export{i as extractClientKeys,_ as extractKeys,a as extractSharedKeys,h as runCodegen,p as setupArkEnv,m as withArkEnv};
|
|
76
103
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["chokidarWatch"],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { watch as chokidarWatch } from \"chokidar\";\n\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __arkenv_watcher__: import(\"chokidar\").FSWatcher | undefined;\n}\n\n/**\n * Configuration options for the ArkEnv Next.js integration.\n *\n * @example\n * ```ts\n * const configOptions: ArkEnvConfigOptions = {\n * schemaPath: \"./src/env.ts\",\n * outputPath: \"./src/generated/env.gen.ts\"\n * };\n * ```\n */\nexport type ArkEnvConfigOptions = {\n\t/**\n\t * Specify the path to the schema definition file.\n\t *\n\t * Defaults to searching for `\"src/env.ts\"` or `\"env.ts\"` in the project root.\n\t *\n\t * @default \"src/env.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * schemaPath: \"./src/env.ts\"\n\t * });\n\t * ```\n\t */\n\tschemaPath?: string;\n\n\t/**\n\t * Specify the path where the generated file (`env.gen.ts`) should be written.\n\t *\n\t * Defaults to `\"generated/env.gen.ts\"` in the same directory as the schema file.\n\t *\n\t * @default \"[schemaDirectory]/generated/env.gen.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * outputPath: \"./src/generated/env.gen.ts\"\n\t * });\n\t * ```\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Specify the configuration layout.\n\t *\n\t * - `\"simple\"` (default): A single `env.ts` schema file.\n\t * - `\"strict\"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).\n\t *\n\t * @default \"simple\"\n\t */\n\tlayout?: \"simple\" | \"strict\";\n};\n\n/**\n * Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.\n *\n * @param nextConfig The Next.js configuration object or function\n * @param options Optional configuration paths for schema and output files\n * @returns The Next.js configuration object unchanged\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T {\n\t// 1. Locate the env.ts schema file or strict schema directory\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\t// Auto-detect layout if not specified\n\tlet exists = false;\n\tif (schemaPath) {\n\t\tif (fs.existsSync(schemaPath)) {\n\t\t\texists = true;\n\t\t} else {\n\t\t\tconst ext = path.extname(schemaPath);\n\t\t\tif (ext) {\n\t\t\t\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\t\t\t\tif (fs.existsSync(baseWithoutExt)) {\n\t\t\t\t\texists = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!schemaPath || !exists) {\n\t\tthrow new Error(\n\t\t\t`[ArkEnv] Could not find schema file at ${\n\t\t\t\toptions?.schemaPath || \"src/env.ts or env.ts\"\n\t\t\t}. Please specify 'schemaPath' in withArkEnv options.`,\n\t\t);\n\t}\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\toptions?.layout,\n\t);\n\n\t// 2. Determine outputPath (defaults to generated/env.gen.ts in the same directory as schemaPath/baseDir)\n\tconst defaultOutputDir =\n\t\tresolvedLayout === \"strict\" && baseDir ? baseDir : path.dirname(schemaPath);\n\tconst defaultOutputPath = path.join(\n\t\tdefaultOutputDir,\n\t\t\"generated\",\n\t\t\"env.gen.ts\",\n\t);\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\t// 3. Run initial code generation\n\ttry {\n\t\trunCodegen(schemaPath, outputPath, resolvedLayout);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`[ArkEnv] Failed to generate env.gen.ts: ${message}`);\n\t}\n\n\t// 4. Initialize development file watcher if in dev mode\n\tconst isDev =\n\t\tprocess.env.NODE_ENV === \"development\" ||\n\t\tprocess.env.NEXT_PHASE === \"phase-development-server\";\n\tif (isDev) {\n\t\tconst watchPaths =\n\t\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t\t? [\n\t\t\t\t\t\tpath.join(baseDir, \"internal\", \"shared.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"client.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"server.ts\"),\n\t\t\t\t\t].filter(fs.existsSync)\n\t\t\t\t: [schemaPath];\n\t\twatchSchema(watchPaths, outputPath, resolvedLayout);\n\t}\n\n\treturn nextConfig;\n}\n\n/**\n * Find the path to the schema file in the project.\n *\n * @returns The absolute path to the schema file, or null if not found\n */\n/**\n * Resolve the layout (simple vs strict) and the base directory from a schema path.\n *\n * Auto-detects layout when `layoutOption` is not provided. When `layoutOption`\n * is `\"strict\"`, validates that the required split files exist and throws a\n * descriptive error if either is missing.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param layoutOption The explicit layout option, if provided\n * @returns The resolved layout and base directory\n * @throws An error if strict layout files are missing\n */\nfunction resolveLayout(\n\tschemaPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n): { layout: \"simple\" | \"strict\"; baseDir: string } {\n\tconst checkStrict = (dir: string) =>\n\t\tfs.existsSync(path.join(dir, \"internal\", \"shared.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"client.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"server.ts\"));\n\n\tconst resolveBaseDir = (p: string): string => {\n\t\t// Normalize: if schemaPath has an extension, try the extensionless form as a dir\n\t\tconst ext = path.extname(p);\n\t\tconst baseWithoutExt = ext ? p.slice(0, -ext.length) : p;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory()\n\t\t) {\n\t\t\treturn baseWithoutExt;\n\t\t}\n\t\treturn p;\n\t};\n\n\tif (!layoutOption) {\n\t\t// Auto-detect\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tif (checkStrict(resolved)) {\n\t\t\t\treturn { layout: \"strict\", baseDir: resolved };\n\t\t\t}\n\t\t\treturn { layout: \"simple\", baseDir: resolved };\n\t\t}\n\n\t\t// schemaPath is a file — check surrounding dirs\n\t\tconst parent = path.dirname(schemaPath);\n\t\tconst ext = path.extname(schemaPath);\n\t\tconst baseWithoutExt = ext ? schemaPath.slice(0, -ext.length) : schemaPath;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory() &&\n\t\t\tcheckStrict(baseWithoutExt)\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: baseWithoutExt };\n\t\t}\n\t\tif (checkStrict(parent)) {\n\t\t\treturn { layout: \"strict\", baseDir: parent };\n\t\t}\n\t\tif (\n\t\t\tpath.basename(parent) === \"internal\" &&\n\t\t\tcheckStrict(path.dirname(parent))\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: path.dirname(parent) };\n\t\t}\n\t\treturn { layout: \"simple\", baseDir: schemaPath };\n\t}\n\n\tif (layoutOption === \"strict\") {\n\t\t// Resolve baseDir for an explicit strict layout\n\t\tlet baseDir: string;\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tbaseDir = resolved;\n\t\t} else {\n\t\t\tconst parent = path.dirname(schemaPath);\n\t\t\tif (path.basename(parent) === \"internal\") {\n\t\t\t\tbaseDir = path.dirname(parent);\n\t\t\t} else {\n\t\t\t\tbaseDir = parent;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that required split files exist\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\t\tif (!fs.existsSync(clientPath) || !fs.existsSync(sharedPath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`[ArkEnv] Strict layout requires \"${clientPath}\" and \"${sharedPath}\" to exist. ` +\n\t\t\t\t\t`Ensure both files are present or remove the 'layout: \"strict\"' option to let ArkEnv auto-detect.`,\n\t\t\t);\n\t\t}\n\n\t\treturn { layout: \"strict\", baseDir };\n\t}\n\n\t// layoutOption === \"simple\"\n\treturn { layout: \"simple\", baseDir: schemaPath };\n}\n\nfunction findSchemaPath(): string | null {\n\tconst possiblePaths = [\n\t\tpath.join(process.cwd(), \"src\", \"env.ts\"),\n\t\tpath.join(process.cwd(), \"env.ts\"),\n\t];\n\tfor (const p of possiblePaths) {\n\t\tif (fs.existsSync(p)) return p;\n\t}\n\n\tconst possibleDirs = [\n\t\tpath.join(process.cwd(), \"src\", \"env\"),\n\t\tpath.join(process.cwd(), \"env\"),\n\t];\n\tfor (const d of possibleDirs) {\n\t\tif (\n\t\t\tfs.existsSync(d) &&\n\t\t\tfs.existsSync(path.join(d, \"internal\", \"shared.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"client.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"server.ts\"))\n\t\t) {\n\t\t\treturn d;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Watch the schema file for changes and trigger codegen.\n *\n * @param schemaPath The absolute path to the schema file, or an array of paths to watch\n * @param outputPath The absolute path to the generated output file\n * @param layout The resolved layout to pass through to codegen on each change\n */\nfunction watchSchema(\n\tschemaPath: string | string[],\n\toutputPath: string,\n\tlayout?: \"simple\" | \"strict\",\n) {\n\tconst previousWatcher = globalThis.__arkenv_watcher__;\n\tif (previousWatcher && typeof previousWatcher.close === \"function\") {\n\t\tpreviousWatcher.close().catch((err: unknown) => {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\tconsole.error(\n\t\t\t\t`[ArkEnv Watcher] Failed to close previous watcher: ${message}`,\n\t\t\t);\n\t\t});\n\t}\n\n\ttry {\n\t\tconst watcher = chokidarWatch(schemaPath, { ignoreInitial: true });\n\t\tglobalThis.__arkenv_watcher__ = watcher;\n\n\t\twatcher.on(\"change\", () => {\n\t\t\ttry {\n\t\t\t\tconst mainSchemaPath = Array.isArray(schemaPath)\n\t\t\t\t\t? schemaPath[0]\n\t\t\t\t\t: schemaPath;\n\t\t\t\trunCodegen(mainSchemaPath, outputPath, layout);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[ArkEnv Watcher] Failed to regenerate env.gen.ts: ${message}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t} catch (err: unknown) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\tconsole.error(\n\t\t\t`[ArkEnv Watcher] Failed to start watch on ${schemaPath}: ${message}`,\n\t\t);\n\t}\n}\n\n/**\n * Run code generation to read the schema file and generate the env.gen.ts factory.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param outputPath The absolute path to the generated output file\n * @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted\n * @throws An error if strict layout files are missing when `layoutOption` is `\"strict\"`\n */\nexport function runCodegen(\n\tschemaPath: string,\n\toutputPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n) {\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tlayoutOption,\n\t);\n\n\tlet generatedCode = \"\";\n\tif (resolvedLayout === \"strict\") {\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\n\t\tconst clientContent = fs.existsSync(clientPath)\n\t\t\t? fs.readFileSync(clientPath, \"utf-8\")\n\t\t\t: \"\";\n\t\tconst sharedContent = fs.existsSync(sharedPath)\n\t\t\t? fs.readFileSync(sharedPath, \"utf-8\")\n\t\t\t: \"\";\n\n\t\tconst clientKeys = extractClientKeys(clientContent);\n\t\tconst sharedKeys = extractSharedKeys(sharedContent);\n\n\t\tgeneratedCode = generateClientFactoryCode(clientKeys, sharedKeys);\n\t} else {\n\t\tconst fileContent = fs.readFileSync(schemaPath, \"utf-8\");\n\t\tconst { clientKeys, sharedKeys } = extractKeys(fileContent);\n\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys);\n\t}\n\n\t// Ensure parent directory exists\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\n\t// Write if changed to avoid unnecessary filesystem/watcher triggers\n\tlet shouldWrite = true;\n\tif (fs.existsSync(outputPath)) {\n\t\tconst existingContent = fs.readFileSync(outputPath, \"utf-8\");\n\t\tif (existingContent === generatedCode) {\n\t\t\tshouldWrite = false;\n\t\t}\n\t}\n\n\tif (shouldWrite) {\n\t\tfs.writeFileSync(outputPath, generatedCode, \"utf-8\");\n\t}\n}\n\n/**\n * Statically extract client and shared keys from the schema content.\n *\n * @param content The schema file string content\n * @returns An object containing the extracted client and shared keys\n */\nexport function extractKeys(content: string): {\n\tclientKeys: string[];\n\tsharedKeys: string[];\n} {\n\tconst clientKeys: string[] = [];\n\tconst sharedKeys: string[] = [];\n\n\t// Extract client block\n\tconst clientBlock = extractBlock(content, \"client\");\n\tif (clientBlock) {\n\t\tclientKeys.push(...parseBlockKeys(clientBlock));\n\t}\n\n\t// Extract shared block\n\tconst sharedBlock = extractBlock(content, \"shared\");\n\tif (sharedBlock) {\n\t\tsharedKeys.push(...parseBlockKeys(sharedBlock));\n\t}\n\n\treturn { clientKeys, sharedKeys };\n}\n\n/**\n * Extract a specific block from the schema content by name.\n *\n * @param content The schema file string content\n * @param blockName The name of the block to extract (e.g., 'client' or 'shared')\n * @returns The contents of the block, or null if not found\n */\nfunction extractBlock(content: string, blockName: string): string | null {\n\t// Find \"\\bblockName\\s*:\\s*{\" or \"\\bblockName\\s*:\\s*type({\"\n\tconst regex = new RegExp(\n\t\t`\\\\b${blockName}\\\\s*:\\\\s*(?:[a-zA-Z0-9_$.]+\\\\s*\\\\(\\\\s*)?\\\\{`,\n\t\t\"g\",\n\t);\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Parse environment variable keys from a block's content.\n *\n * @param blockContent The raw content of the block\n * @returns An array of parsed environment variable keys\n */\nfunction parseBlockKeys(blockContent: string): string[] {\n\tconst keys: string[] = [];\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\tlet currentToken = \"\";\n\tlet lastStringContent = \"\";\n\tlet braceDepth = 0;\n\n\tfor (let i = 0; i < blockContent.length; i++) {\n\t\tconst char = blockContent[i];\n\t\tconst nextChar = blockContent[i + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && blockContent[i - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t\tlastStringContent = currentToken;\n\t\t\t\tcurrentToken = \"\";\n\t\t\t} else {\n\t\t\t\tcurrentToken += char;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Start comments/strings\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tcurrentToken = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceDepth++;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"}\") {\n\t\t\tbraceDepth--;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \":\") {\n\t\t\tif (braceDepth === 0) {\n\t\t\t\tconst key = currentToken.trim() || lastStringContent.trim();\n\t\t\t\tif (key) {\n\t\t\t\t\tkeys.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (/[a-zA-Z0-9_$]/.test(char)) {\n\t\t\tcurrentToken += char;\n\t\t} else if (char === \",\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t}\n\t}\n\n\treturn keys;\n}\n\n/**\n * Generate the TypeScript factory code for the tailored arkenv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @returns The generated TypeScript source code string\n */\nfunction generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { arkenv as coreArkenv } from \"@arkenv/nextjs\";\nimport type { Infer } from \"@arkenv/nextjs\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function arkenv<\n\tconst TServer extends Record<string, any> = {},\n\tconst TClient extends Record<string, any> = {},\n\tconst TShared extends Record<string, any> = {},\n>(options: {\n\tserver?: TServer;\n\tclient?: TClient & {\n\t\t[K in keyof TClient]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t};\n\tshared?: TShared;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\treturn coreArkenv({\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any) as any;\n}\n\nexport default arkenv;\n`;\n}\n\n/**\n * Generate the TypeScript factory code for the strict-layout `arkenv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @returns The generated TypeScript source code string\n */\nfunction generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { arkenv as coreArkenv } from \"@arkenv/nextjs/client\";\n\nexport { type } from \"@arkenv/nextjs/client\";\n\nexport function arkenv<\n\tconst TSchema extends Record<string, any> = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema & {\n\t\t[K in keyof TSchema]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t},\n\toptions?: {\n\t\textends?: [...TExtends];\n\t},\n) {\n\treturn coreArkenv<TSchema, TExtends>(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);\n}\n\nexport default arkenv;\n`;\n}\n\n/**\n * Extract env var keys from a strict-layout `client.ts` file.\n *\n * Locates the first `arkenv({...})` call and delegates to `parseBlockKeys`\n * to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `client.ts`\n * @returns An array of env var key names found in the client schema\n */\nexport function extractClientKeys(content: string): string[] {\n\tconst block = extractClientBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract env var keys from a strict-layout `internal/shared.ts` file.\n *\n * Locates the `SharedSchema = ...({...})` assignment and delegates to\n * `parseBlockKeys` to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns An array of env var key names found in the shared schema\n */\nexport function extractSharedKeys(content: string): string[] {\n\tconst block = extractSharedBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract the schema object body from a strict-layout `client.ts` file.\n *\n * Matches the first `arkenv(...)` call, then performs brace-balanced\n * traversal while respecting strings and comments to find the boundaries\n * of the first argument object.\n *\n * @param content The source text of `client.ts`\n * @returns The raw text inside the first `{...}` argument, or `null` if not found\n */\nfunction extractClientBlock(content: string): string | null {\n\tconst regex = /\\barkenv\\s*\\(\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract the schema object body from a strict-layout `internal/shared.ts` file.\n *\n * Matches the `SharedSchema = ...({...})` assignment, then performs\n * brace-balanced traversal while respecting strings and comments to find\n * the boundaries of the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns The raw text inside the `{...}` schema object, or `null` if not found\n */\nfunction extractSharedBlock(content: string): string | null {\n\tconst regex = /\\bSharedSchema\\s*=\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n"],"mappings":"iFAsEA,SAAgB,EAAc,EAAe,EAAkC,CAE9E,IAAM,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,GAAgB,CAGf,EAAS,GACb,GAAI,EACH,GAAI,EAAG,WAAW,EAAW,CAC5B,EAAS,OACH,CACN,IAAM,EAAM,EAAK,QAAQ,EAAW,CACpC,GAAI,EAAK,CACR,IAAM,EAAiB,EAAW,MAAM,EAAG,CAAC,EAAI,OAAO,CACnD,EAAG,WAAW,EAAe,GAChC,EAAS,KAMb,GAAI,CAAC,GAAc,CAAC,EACnB,MAAU,MAC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S,IACZ,IACU,IAAS,KACnB,IAED,IAOD,OAJI,IAAe,EACX,EAAQ,MAAM,EAAY,EAAQ,EAAE,CAGrC"}
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n\textractBlock,\n\textractClientKeys,\n\textractSharedKeys,\n\tfindSchemaPath,\n\tparseBlockKeys,\n\tresolveLayout,\n\twatchSchema,\n} from \"@arkenv/build\";\nimport { createJiti } from \"jiti\";\n\nexport { extractClientKeys, extractSharedKeys };\n\nlet hasWarnedSimpleLayout = false;\n\nfunction normalizeLayout(\n\tlayout: ArkEnvConfigOptions[\"layout\"],\n): \"simple\" | \"strict\" | undefined {\n\tif (layout === \"simple\") {\n\t\tif (process.env.NODE_ENV === \"development\" && !hasWarnedSimpleLayout) {\n\t\t\thasWarnedSimpleLayout = true;\n\t\t\tconsole.warn(\n\t\t\t\t\"⚠️ [arkenv] The 'simple' layout option is deprecated and will be removed in the next major version. Use 'flat' instead.\",\n\t\t\t);\n\t\t}\n\t\treturn \"simple\";\n\t}\n\tif (layout === \"flat\") {\n\t\treturn \"simple\";\n\t}\n\treturn layout;\n}\n\n/**\n * Configuration options for the ArkEnv Next.js integration.\n *\n * @example\n * ```ts\n * const configOptions: ArkEnvConfigOptions = {\n * schemaPath: \"./src/env.ts\",\n * outputPath: \"./src/generated/env.gen.ts\"\n * };\n * ```\n */\nexport type ArkEnvConfigOptions = {\n\t/**\n\t * Specify the path to the schema definition file.\n\t *\n\t * Defaults to searching for `\"src/env.ts\"` or `\"env.ts\"` in the project root.\n\t *\n\t * @default \"src/env.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * schemaPath: \"./src/env.ts\"\n\t * });\n\t * ```\n\t */\n\tschemaPath?: string;\n\n\t/**\n\t * Specify the path where the generated file (`env.gen.ts`) should be written.\n\t *\n\t * Defaults to `\"generated/env.gen.ts\"` in the same directory as the schema file.\n\t *\n\t * @default \"[schemaDirectory]/generated/env.gen.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * outputPath: \"./src/generated/env.gen.ts\"\n\t * });\n\t * ```\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Specify the configuration layout.\n\t *\n\t * - `\"flat\"` (default): A single `env.ts` schema file.\n\t * - `\"strict\"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).\n\t *\n\t * @default \"flat\"\n\t */\n\tlayout?:\n\t\t| \"flat\"\n\t\t| \"strict\"\n\t\t/** @deprecated Use `\"flat\"` instead. `\"simple\"` will be removed in the next major version. */\n\t\t| \"simple\";\n\n\t/**\n\t * Force standard mode code generation.\n\t *\n\t * When `true`, the generated `env.gen.ts` imports from `@arkenv/nextjs/standard/*`\n\t * instead of `@arkenv/nextjs/*`, ensuring the Standard Schema engine (`@arkenv/standard`)\n\t * is used and `arktype` is never bundled. This is set automatically when importing from\n\t * `@arkenv/nextjs/standard/config`, but can be toggled manually for custom setups.\n\t *\n\t * @default false\n\t */\n\tstandard?: boolean;\n\n\t/**\n\t * Enable or disable build-time environment variable validation during build/dev startup.\n\t *\n\t * @default true\n\t */\n\tvalidate?: boolean;\n\n\t/**\n\t * Enable or disable automatic code generation of the `env.gen.ts` file.\n\t *\n\t * @default true\n\t */\n\tcodegen?: boolean;\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\t// 1. Locate the env.ts schema file or strict schema directory\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\t// Auto-detect layout if not specified\n\tlet exists = false;\n\tif (schemaPath) {\n\t\tif (fs.existsSync(schemaPath)) {\n\t\t\texists = true;\n\t\t} else {\n\t\t\tconst ext = path.extname(schemaPath);\n\t\t\tif (ext) {\n\t\t\t\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\t\t\t\tif (fs.existsSync(baseWithoutExt)) {\n\t\t\t\t\texists = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!schemaPath || !exists) {\n\t\tthrow new Error(\n\t\t\t`[ArkEnv] Could not find schema file at ${\n\t\t\t\toptions?.schemaPath || \"src/env.ts or env.ts\"\n\t\t\t}. Please specify 'schemaPath' in setupArkEnv options.`,\n\t\t);\n\t}\n\n\tconst normalizedLayout = normalizeLayout(options?.layout);\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tnormalizedLayout,\n\t);\n\n\t// 2. Determine outputPath (defaults to generated/env.gen.ts in the same directory as schemaPath/baseDir)\n\tconst defaultOutputDir =\n\t\tresolvedLayout === \"strict\" && baseDir ? baseDir : path.dirname(schemaPath);\n\tconst defaultOutputPath = path.join(\n\t\tdefaultOutputDir,\n\t\t\"generated\",\n\t\t\"env.gen.ts\",\n\t);\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\t// 3. Run initial code generation if enabled\n\tconst codegen = options?.codegen ?? true;\n\tif (codegen) {\n\t\ttry {\n\t\t\trunCodegen(schemaPath, outputPath, resolvedLayout, options?.standard);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tthrow new Error(`[ArkEnv] Failed to generate env.gen.ts: ${message}`);\n\t\t}\n\t}\n\n\t// 4. Validate schema against environment variables\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 sharedPath = fs.existsSync(path.join(dir, \"shared.ts\"))\n\t\t\t\t? path.join(dir, \"shared.ts\")\n\t\t\t\t: path.join(dir, \"shared.js\");\n\n\t\t\tconst aliases: Record<string, string> = {\n\t\t\t\t\"server-only\": sharedPath,\n\t\t\t\t\"./script\": sharedPath,\n\t\t\t\t\"./script.tsx\": sharedPath,\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\tconsole.error(\"\\n❌ [ArkEnv] Environment validation failed:\");\n\t\t\tconsole.error(error instanceof Error ? error.message : String(error));\n\t\t\tconsole.error(\"\");\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\t// 5. Initialize development file watcher if in dev mode and codegen is enabled\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(watchPaths, () => {\n\t\t\trunCodegen(schemaPath, outputPath, resolvedLayout, options?.standard);\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\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) {\n\tconst normalizedLayout = normalizeLayout(layoutOption);\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\t!!forceStandard ||\n\t\t\tclientContent.includes(\"@arkenv/standard\") ||\n\t\t\tclientContent.includes(\"arkenv/standard\") ||\n\t\t\tsharedContent.includes(\"@arkenv/standard\") ||\n\t\t\tsharedContent.includes(\"arkenv/standard\");\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 =\n\t\t\t!!forceStandard ||\n\t\t\tfileContent.includes(\"@arkenv/standard\") ||\n\t\t\tfileContent.includes(\"arkenv/standard\");\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\t// Ensure parent directory exists\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\n\t// Write if changed to avoid unnecessary filesystem/watcher triggers\n\tlet shouldWrite = true;\n\tif (fs.existsSync(outputPath)) {\n\t\tconst existingContent = fs.readFileSync(outputPath, \"utf-8\");\n\t\tif (existingContent === generatedCode) {\n\t\t\tshouldWrite = false;\n\t\t}\n\t}\n\n\tif (shouldWrite) {\n\t\tfs.writeFileSync(outputPath, generatedCode, \"utf-8\");\n\t}\n}\n\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\t// Strip outer braces if present\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) {\n\t\t\tclientKeys.push(...parseBlockKeys(clientBlock));\n\t\t}\n\t\tconst sharedBlock = extractBlock(args.schemaArg, \"shared\");\n\t\tif (sharedBlock) {\n\t\t\tsharedKeys.push(...parseBlockKeys(sharedBlock));\n\t\t}\n\t} else {\n\t\t// New flat layout\n\t\tconst optionExposedKeys: string[] = [];\n\t\tif (args.optionsArg) {\n\t\t\tconst exposeMatch =\n\t\t\t\targs.optionsArg.match(/exposeToClient\\s*:\\s*\\[([\\s\\S]*?)\\]/) ||\n\t\t\t\targs.optionsArg.match(/expose\\s*:\\s*\\[([\\s\\S]*?)\\]/) ||\n\t\t\t\targs.optionsArg.match(/shared\\s*:\\s*\\[([\\s\\S]*?)\\]/);\n\t\t\tif (exposeMatch) {\n\t\t\t\tconst matches = exposeMatch[1].matchAll(/['\"`](.*?)['\"`]/g);\n\t\t\t\tfor (const match of matches) {\n\t\t\t\t\toptionExposedKeys.push(match[1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of topKeys) {\n\t\t\t// NODE_ENV is implicitly shared as Next.js automatically inlines and replaces references to process.env.NODE_ENV in browser bundles.\n\t\t\t// See: https://nextjs.org/docs/app/guides/environment-variables\n\t\t\tif (optionExposedKeys.includes(key) || key === \"NODE_ENV\") {\n\t\t\t\tsharedKeys.push(key);\n\t\t\t} else if (key.startsWith(\"NEXT_PUBLIC_\")) {\n\t\t\t\tclientKeys.push(key);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { clientKeys, sharedKeys, isLegacy };\n}\n\n/**\n * Generate the triple-tab indented runtime environment variables mapping.\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\n/**\n * Generate the TypeScript factory code for the tailored arkenv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @param isStandard Whether standard mode is used\n * @returns The generated TypeScript source code string\n */\nfunction 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 typeExport = isStandard\n\t\t? \"\"\n\t\t: '\\nexport { type } from \"@arkenv/nextjs\";\\n';\n\tconst callPrefix = \"coreArkenv\";\n\n\treturn `${GENERATED_HEADER}\nimport { ${coreName} as coreArkenv } from \"${importPath}\";\n${typeExport}\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\n/**\n * Generate the TypeScript factory code for the Flat Layout arkenv helper.\n *\n * @remarks\n * **Architecture tripwire:** Do not statically compile the schema here or\n * reference internal-only types (the `$` scope or `MergeExtends`).\n *\n * - **Generic wrapper:** The factory must stay generic because the concrete\n * schema is owned by the user-land `env.ts`.\n * - **Type strategy:** It intentionally returns the full schema type to ensure\n * flawless Server Component autocomplete.\n * - **Security boundary:** Client-side protection is deliberately deferred to\n * the runtime Proxy in `@arkenv/nextjs`, which throws on unauthorized access.\n *\n * 📖 See ADR-0010: Flat layout codegen and type inference strategy\n * (`docs/adr/0010-flat-layout-codegen-type-strategy.md`).\n */\nfunction 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 typeExport = isStandard\n\t\t? \"\"\n\t\t: '\\nexport { type } from \"@arkenv/nextjs\";\\n';\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${typeExport}\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\t// Types expose the full schema for a great DX on the server; the runtime\n\t// Proxy from \\`@arkenv/nextjs\\` enforces the security boundary by throwing\n\t// when a server-only variable is accessed on the client.\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 * Generate the TypeScript factory code for the strict-layout `arkenv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @param isStandard Whether standard mode is used\n * @returns The generated TypeScript source code string\n */\nfunction 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 typeExport = isStandard\n\t\t? \"\"\n\t\t: '\\nexport { type } from \"@arkenv/nextjs/client\";\\n';\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${typeExport}\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"],"mappings":"kSAgBA,IAAI,EAAwB,GAE5B,SAAS,EACR,EACkC,CAalC,OAZI,IAAW,UACV,QAAQ,IAAI,WAAa,eAAiB,CAAC,IAC9C,EAAwB,GACxB,QAAQ,KACP,0HACA,EAEK,UAEJ,IAAW,OACP,SAED,EA6FR,SAAgB,EACf,EACA,EACO,CAEP,IAAM,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,GAAgB,CAGf,EAAS,GACb,GAAI,EACH,GAAI,EAAG,WAAW,EAAW,CAC5B,EAAS,OACH,CACN,IAAM,EAAM,EAAK,QAAQ,EAAW,CACpC,GAAI,EAAK,CACR,IAAM,EAAiB,EAAW,MAAM,EAAG,CAAC,EAAI,OAAO,CACnD,EAAG,WAAW,EAAe,GAChC,EAAS,KAMb,GAAI,CAAC,GAAc,CAAC,EACnB,MAAU,MACT,0CACC,GAAS,YAAc,uBACvB,uDACD,CAKF,GAAM,CAAE,OAAQ,EAAgB,WAAY,EAC3C,EAHwB,EAAgB,GAAS,OAIjC,CAChB,CAGK,EACL,IAAmB,UAAY,EAAU,EAAU,EAAK,QAAQ,EAAW,CACtE,EAAoB,EAAK,KAC9B,EACA,YACA,aACA,CACK,EAAa,GAAS,WACzB,EAAK,QAAQ,EAAQ,WAAW,CAChC,EAGG,EAAU,GAAS,SAAW,GACpC,GAAI,EACH,GAAI,CACH,EAAW,EAAY,EAAY,EAAgB,GAAS,SAAS,OAC7D,EAAgB,CACxB,IAAM,EAAU,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,CACtE,M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AfnD,EAChB,GACA;;EAcS;;;;;;;;;;;;;;;;KAVO,EAChB,oBACA,2CAwBY;;;;;;;KAOX,EAAgB;;;aA9BD,EAChB,GACA,0DA+BoB;;EAEtB,IAcF,SAAS,EACR,EACA,EACA,EACS,CACT,IAAM,EAAkB,EAAwB,EAAY,EAAW,CAgBvE,MAAO,GAAG,EAAiB;wCAfR,EAChB,iCACA,wBAcoD,IATpC,EAChB,GACA;4CAOmE;EAZnD,EAChB,GACA;;EAWS;;;;;;;;;;;;;;;;;;;;;;;;KANO,EAChB,6CACA,oDA4BY;;;;KAIX,EAAgB;;;;EAInB"}
|
|
@@ -186,5 +186,5 @@ type InferType<T> = T extends StandardSchemaV1<infer _Input, infer Output> ? Out
|
|
|
186
186
|
//#region ../internal/types/dist/schema.d.ts
|
|
187
187
|
type SchemaShape = Record<string, unknown>;
|
|
188
188
|
//#endregion
|
|
189
|
-
export { $ as i, InferType as n,
|
|
190
|
-
//# 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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
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,CAAAA;MAChF,cAAA,GAAiBgB,EAAAA,aAAejB,iCAAAA,CAAkCG,EAAAA;IAAAA;IAEpEoB,UAAAA;IACAC,IAAAA,EAAM1B,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCQ,UAAAA,CAAWN,CAAAA;MAC1E,cAAA;IAAA;IAEFwB,MAAAA;IACAC,KAAAA;IACAC,OAAAA,EAAS7B,SAAAA,CAAUM,SAAAA,CAAUL,sCAAAA,CAAuCS,aAAAA,CAAcP,CAAAA;MAChF,cAAA;IA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<infer _Input, infer Output> ? Out
|
|
|
186
186
|
//#region ../internal/types/dist/schema.d.ts
|
|
187
187
|
type SchemaShape = Record<string, unknown>;
|
|
188
188
|
//#endregion
|
|
189
|
-
export { $ as i, InferType as n,
|
|
190
|
-
//# sourceMappingURL=index-
|
|
189
|
+
export { $ as a, Dict as i, InferType as n, StandardSchemaV1 as r, SchemaShape as t };
|
|
190
|
+
//# sourceMappingURL=index-Dypl5Zzg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-Dypl5Zzg.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,CAA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C,WAAAA;EAAAA;EFjDhDnD;EAAAA,UEoDUmD,WAAAA;IFlDVjD;IAAAA,SEoDayD,GAAAA,EAAKT,WAAAA;EAAAA;EFlDVtE;EAAAA,UEqDEoD,KAAAA,2BAAgCJ,KAAAA,UAAeD,eAAAA,CAAgBK,KAAAA,CAAMJ,KAAAA,EAAOC,MAAAA;EFnDpFlC;EAAAA,KEsDG4C,UAAAA,gBAA0BZ,eAAAA,IAAmBA,eAAAA,CAAgBY,UAAAA,CAAWR,MAAAA;EFlD7E3C;EAAAA,KEoDKoD,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(`./arkenv-internal-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`./config-DNJIS9zz.cjs`);const e=require(`./arkenv-internal-Dz0mDRKT.cjs`),t=require(`./script-CUpLLTKJ.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,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return n.type}});
|
|
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 { Infer } from \"@arkenv/core\";\nexport { type } from \"@arkenv/core\";\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,14 +1,36 @@
|
|
|
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-DSWuhk88.cjs";
|
|
4
|
+
import { EnvSchema, Infer, Infer as Infer$1, type } from "@arkenv/core";
|
|
5
|
+
import { distill, type as type$1 } 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
*/
|
|
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$1.infer<TSchema, $>>, Extract<keyof distill.Out<type$1.infer<TSchema, $>>, ClientVisibleKeys<TSchema, TExpose>>> & MergeExtends<TExtends>>;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use the unified flat layout signature instead: `arkenv(schema, options)`
|
|
12
34
|
*/
|
|
13
35
|
declare function arkenv<const TServer extends SchemaShape = {}, const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}>(options: {
|
|
14
36
|
server?: EnvSchema<TServer>;
|
|
@@ -17,5 +39,5 @@ declare function arkenv<const TServer extends SchemaShape = {}, const TClient ex
|
|
|
17
39
|
runtimeEnv: Record<keyof TClient | keyof TShared, unknown> & Record<string, unknown>;
|
|
18
40
|
}): Readonly<Infer$1<TServer & TClient & TShared>>;
|
|
19
41
|
//#endregion
|
|
20
|
-
export { type Infer, arkenv, arkenv as default, type };
|
|
42
|
+
export { ArkEnvScript, type ArkEnvScriptProps, type Infer, arkenv, arkenv as default, type };
|
|
21
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,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,IAC9B,OAAA,OACO,OAAA,CAAQ,GAAA,CAAI,MAAA,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,OAAA,CAAM,OAAA,GAAU,OAAA,GAAU,OAAA"}
|