@arkenv/nextjs 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -2
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/config.cjs +43 -33
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +14 -29
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.ts +14 -29
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +43 -33
- package/dist/config.js.map +1 -1
- package/dist/create-env-B6DmIK3X.js +2 -0
- package/dist/create-env-B6DmIK3X.js.map +1 -0
- package/dist/create-env-C_h541CQ.cjs +2 -0
- package/dist/create-env-C_h541CQ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +28 -12
- 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 +21 -12
- package/dist/react-server.d.cts.map +1 -1
- package/dist/react-server.d.ts +21 -12
- 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-BJ1JRyJi.cjs +2 -0
- package/dist/script-BJ1JRyJi.cjs.map +1 -0
- package/dist/script-C06S6xXP.d.cts +21 -0
- package/dist/script-C06S6xXP.d.cts.map +1 -0
- package/dist/script-CAxxM5Zm.d.ts +21 -0
- package/dist/script-CAxxM5Zm.d.ts.map +1 -0
- package/dist/script-DB7wIIvT.js +2 -0
- package/dist/script-DB7wIIvT.js.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -2
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +4 -2
- 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.d.cts +1 -2
- package/dist/shared.d.cts.map +1 -1
- package/dist/shared.d.ts +1 -2
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +1 -1
- package/dist/{index-CRUkF6-E.d.cts → types-BzoNhHhq.d.ts} +10 -2
- package/dist/types-BzoNhHhq.d.ts.map +1 -0
- package/dist/{index-DvODqC0J.d.ts → types-DyUrJJZq.d.cts} +10 -2
- package/dist/types-DyUrJJZq.d.cts.map +1 -0
- package/package.json +10 -6
- package/dist/create-env-Dayn7K9n.cjs +0 -2
- package/dist/create-env-Dayn7K9n.cjs.map +0 -1
- package/dist/create-env-DocUkgSM.js +0 -2
- package/dist/create-env-DocUkgSM.js.map +0 -1
- package/dist/index-CRUkF6-E.d.cts.map +0 -1
- package/dist/index-DvODqC0J.d.ts.map +0 -1
- package/dist/types-8YUW70UX.d.ts +0 -12
- package/dist/types-8YUW70UX.d.ts.map +0 -1
- package/dist/types-BTG7L0mq.d.cts +0 -12
- package/dist/types-BTG7L0mq.d.cts.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./create-env-C_h541CQ.cjs`);require(`./config.cjs`);let t=require(`arkenv`);function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`client`in t||`shared`in t)){if(`server`in t)throw Error(`client entry point only accepts 'client' and 'shared' schemas.`);return e.t(t,!1)}return e.t(t,n,{isServer:!1,strictLayout:`client`})}const r=n;exports.createEnv=n,exports.default=r,Object.defineProperty(exports,`type`,{enumerable:!0,get:function(){return t.type}});
|
|
2
2
|
//# sourceMappingURL=client.cjs.map
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/client.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { Dict, SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<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\truntimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function createEnv<\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\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\textends?: [...TExtends];\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TClient & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"client\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"server\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"client entry point only accepts 'client' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, false);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: false,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["createEnvInternal","arkenv"],"sources":["../src/client.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { Dict, SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<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\truntimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\n/**\n * @deprecated Use the unified flat layout signature instead: `createEnv(schema, options)`\n */\nexport function createEnv<\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\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\textends?: [...TExtends];\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TClient & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"client\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"server\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"client entry point only accepts 'client' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, false);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: false,\n\t\tstrictLayout: \"client\",\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"4LA0CA,SAAgB,EAAU,EAAsB,EAA8B,CAQ7E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAOA,EAAAA,EAAkB,EAAiB,GAAM,CAGjD,OAAOA,EAAAA,EAAkB,EAAiB,EAAmB,CAC5D,SAAU,GACV,aAAc,SACd,CAAC,CAKH,MAAMC,EAAS"}
|
package/dist/client.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as $, r as Dict, t as
|
|
2
|
-
import { t as MergeExtends } from "./types-BTG7L0mq.cjs";
|
|
1
|
+
import { i as $, n as SchemaShape, r as Dict, t as MergeExtends } from "./types-DyUrJJZq.cjs";
|
|
3
2
|
import { distill, type as type$1 } from "arktype";
|
|
4
3
|
import { EnvSchema, type } from "arkenv";
|
|
5
4
|
|
|
@@ -11,6 +10,9 @@ declare function createEnv<const TSchema extends SchemaShape = {}, const TExtend
|
|
|
11
10
|
extends?: [...TExtends];
|
|
12
11
|
runtimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;
|
|
13
12
|
}): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use the unified flat layout signature instead: `createEnv(schema, options)`
|
|
15
|
+
*/
|
|
14
16
|
declare function createEnv<const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
|
|
15
17
|
client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
|
|
16
18
|
shared?: EnvSchema<TShared>;
|
package/dist/client.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;AAUA;;;AAAA,iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,kBACL,OAAA,GAAU,CAAA,sDAEvB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,EAAY,MAAA,OAAa,OAAA,wBAA+B,IAAA;AAAA,IAEvD,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;;;;iBAK7C,SAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cA4BtD,MAAA,SAAM,SAAA"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { i as $, r as Dict, t as
|
|
2
|
-
import { t as MergeExtends } from "./types-8YUW70UX.js";
|
|
1
|
+
import { i as $, n as SchemaShape, r as Dict, t as MergeExtends } from "./types-BzoNhHhq.js";
|
|
3
2
|
import { EnvSchema, type } from "arkenv";
|
|
4
3
|
import { distill, type as type$1 } from "arktype";
|
|
5
4
|
|
|
@@ -11,6 +10,9 @@ declare function createEnv<const TSchema extends SchemaShape = {}, const TExtend
|
|
|
11
10
|
extends?: [...TExtends];
|
|
12
11
|
runtimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;
|
|
13
12
|
}): Readonly<distill.Out<type$1.infer<TSchema, $>> & MergeExtends<TExtends>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use the unified flat layout signature instead: `createEnv(schema, options)`
|
|
15
|
+
*/
|
|
14
16
|
declare function createEnv<const TClient extends SchemaShape = {}, const TShared extends SchemaShape = {}, const TExtends extends readonly unknown[] = []>(options: {
|
|
15
17
|
client?: EnvSchema<TClient> & { [K in keyof TClient]: K extends `NEXT_PUBLIC_${string}` ? unknown : never };
|
|
16
18
|
shared?: EnvSchema<TShared>;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../src/client.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../src/client.ts"],"mappings":";;;;;AAUA;;;AAAA,iBAAgB,SAAA,uBACO,WAAA,sDAAA,CAGtB,MAAA,EAAQ,SAAA,CAAU,OAAA,kBACL,OAAA,GAAU,CAAA,sDAEvB,OAAA;EACC,OAAA,OAAc,QAAA;EACd,UAAA,EAAY,MAAA,OAAa,OAAA,wBAA+B,IAAA;AAAA,IAEvD,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;;;;iBAK7C,SAAA,uBACO,WAAA,6BACA,WAAA,sDAAA,CAErB,OAAA;EACD,MAAA,GAAS,SAAA,CAAU,OAAA,kBACN,OAAA,GAAU,CAAA;EAEvB,MAAA,GAAS,SAAA,CAAU,OAAA;EACnB,OAAA,OAAc,QAAA;EACd,UAAA,EAAY,MAAA,OAAa,OAAA,SAAgB,OAAA,aACxC,MAAA;AAAA,IACE,QAAA,CACH,OAAA,CAAQ,GAAA,CAAI,MAAA,CAAG,KAAA,CAAM,OAAA,GAAU,OAAA,EAAS,CAAA,KAAM,YAAA,CAAa,QAAA;AAAA,cA4BtD,MAAA,SAAM,SAAA"}
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./create-env-
|
|
1
|
+
import{t as e}from"./create-env-B6DmIK3X.js";import{type as t}from"arkenv";function n(t,n){if(t&&typeof t==`object`&&(`runtimeEnv`in t||`client`in t||`shared`in t)){if(`server`in t)throw Error(`client entry point only accepts 'client' and 'shared' schemas.`);return e(t,!1)}return e(t,n,{isServer:!1,strictLayout:`client`})}const r=n;export{n as createEnv,r as default,t as type};
|
|
2
2
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { Dict, SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<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\truntimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\nexport function createEnv<\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\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\textends?: [...TExtends];\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TClient & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"client\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"server\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"client entry point only accepts 'client' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, false);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: false,\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import type { $ } from \"@repo/scope\";\nimport type { Dict, SchemaShape } from \"@repo/types\";\nimport type { EnvSchema } from \"arkenv\";\nimport type { type as at, distill } from \"arktype\";\nimport { createEnvInternal } from \"./create-env\";\nimport type { MergeExtends } from \"./types\";\n\n/**\n * Create a validated, type-safe environment configuration for Next.js applications (Client entry point).\n */\nexport function createEnv<\n\tconst TSchema extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: EnvSchema<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\truntimeEnv: Record<keyof TSchema, string | undefined> & Dict<string>;\n\t},\n): Readonly<distill.Out<at.infer<TSchema, $>> & MergeExtends<TExtends>>;\n\n/**\n * @deprecated Use the unified flat layout signature instead: `createEnv(schema, options)`\n */\nexport function createEnv<\n\tconst TClient extends SchemaShape = {},\n\tconst TShared extends SchemaShape = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(options: {\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\textends?: [...TExtends];\n\truntimeEnv: Record<keyof TClient | keyof TShared, unknown> &\n\t\tRecord<string, unknown>;\n}): Readonly<\n\tdistill.Out<at.infer<TClient & TShared, $>> & MergeExtends<TExtends>\n>;\n\nexport function createEnv(schemaOrOptions: any, optionsOrIsServer?: any): any {\n\tconst isLegacy =\n\t\tschemaOrOptions &&\n\t\ttypeof schemaOrOptions === \"object\" &&\n\t\t(\"runtimeEnv\" in schemaOrOptions ||\n\t\t\t\"client\" in schemaOrOptions ||\n\t\t\t\"shared\" in schemaOrOptions);\n\n\tif (isLegacy) {\n\t\tif (\"server\" in schemaOrOptions) {\n\t\t\tthrow new Error(\n\t\t\t\t\"client entry point only accepts 'client' and 'shared' schemas.\",\n\t\t\t);\n\t\t}\n\t\treturn createEnvInternal(schemaOrOptions, false);\n\t}\n\n\treturn createEnvInternal(schemaOrOptions, optionsOrIsServer, {\n\t\tisServer: false,\n\t\tstrictLayout: \"client\",\n\t});\n}\n\nexport { type } from \"arkenv\";\n\nconst arkenv = createEnv;\nexport default arkenv;\n"],"mappings":"2EA0CA,SAAgB,EAAU,EAAsB,EAA8B,CAQ7E,GANC,GACA,OAAO,GAAoB,WAC1B,eAAgB,GAChB,WAAY,GACZ,WAAY,GAEA,CACb,GAAI,WAAY,EACf,MAAU,MACT,iEACA,CAEF,OAAO,EAAkB,EAAiB,GAAM,CAGjD,OAAO,EAAkB,EAAiB,EAAmB,CAC5D,SAAU,GACV,aAAc,SACd,CAAC,CAKH,MAAM,EAAS"}
|
package/dist/config.cjs
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:fs`);c=s(c,1);let l=require(`node:path`);l=s(l,1);let u=require(`
|
|
2
|
-
`||t===`\r`)&&(
|
|
3
|
-
|
|
4
|
-
`||c===`\r`)&&(i=``,a=``)}return t}function y(e,t){return`/* eslint-disable */
|
|
5
|
-
// prettier-ignore
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:fs`);c=s(c,1);let l=require(`node:path`);l=s(l,1);let u=require(`@arkenv/build`),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(e){let t=e?.schemaPath?l.default.resolve(e.schemaPath):(0,u.findSchemaPath)(),n=!1;if(t)if(c.default.existsSync(t))n=!0;else{let e=l.default.extname(t);if(e){let r=t.slice(0,-e.length);c.default.existsSync(r)&&(n=!0)}}if(!t||!n)throw Error(`[ArkEnv] Could not find schema file at ${e?.schemaPath||`src/env.ts or env.ts`}. Please specify 'schemaPath' in setupArkEnv options.`);let{layout:r,baseDir:i}=(0,u.resolveLayout)(t,f(e?.layout)),a=r===`strict`&&i?i:l.default.dirname(t),o=l.default.join(a,`generated`,`env.gen.ts`),s=e?.outputPath?l.default.resolve(e.outputPath):o;try{h(t,s,r)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`[ArkEnv] Failed to generate env.gen.ts: ${t}`)}(process.env.NODE_ENV===`development`||process.env.NEXT_PHASE===`phase-development-server`)&&(0,u.watchSchema)(r===`strict`&&i?[l.default.join(i,`internal`,`shared.ts`),l.default.join(i,`client.ts`),l.default.join(i,`server.ts`)].filter(c.default.existsSync):[t],()=>{h(t,s,r)})}function m(e,t){return p(t),e}function h(e,t,n){let{layout:r,baseDir:i}=(0,u.resolveLayout)(e,f(n)),a=``;if(r===`strict`){let e=l.default.join(i,`client.ts`),t=l.default.join(i,`internal`,`shared.ts`),n=c.default.existsSync(e)?c.default.readFileSync(e,`utf-8`):``,r=c.default.existsSync(t)?c.default.readFileSync(t,`utf-8`):``;a=C((0,u.extractClientKeys)(n),(0,u.extractSharedKeys)(r))}else{let{clientKeys:t,sharedKeys:n,isLegacy:r}=_(c.default.readFileSync(e,`utf-8`));a=r?x(t,n):S(t,n)}let o=l.default.dirname(t);c.default.existsSync(o)||c.default.mkdirSync(o,{recursive:!0});let s=!0;c.default.existsSync(t)&&c.default.readFileSync(t,`utf-8`)===a&&(s=!1),s&&c.default.writeFileSync(t,a,`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===`
|
|
2
|
+
`||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=[],r=g(e);if(!r)return{clientKeys:t,sharedKeys:n,isLegacy:!1};let i=(0,u.parseBlockKeys)(r.schemaArg.replace(/^\{/,``).replace(/\}$/,``).trim()),a=i.includes(`client`)||i.includes(`server`)||i.includes(`shared`);if(a){let e=(0,u.extractBlock)(r.schemaArg,`client`);e&&t.push(...(0,u.parseBlockKeys)(e));let i=(0,u.extractBlock)(r.schemaArg,`shared`);i&&n.push(...(0,u.parseBlockKeys)(i))}else{let e=[];if(r.optionsArg){let t=r.optionsArg.match(/exposeToClient\s*:\s*\[([\s\S]*?)\]/)||r.optionsArg.match(/expose\s*:\s*\[([\s\S]*?)\]/)||r.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 i)e.includes(r)||r===`NODE_ENV`?n.push(r):r.startsWith(`NEXT_PUBLIC_`)&&t.push(r)}return{clientKeys:t,sharedKeys:n,isLegacy:a}}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(`
|
|
3
|
+
`)}const y=`/* eslint-disable */
|
|
6
4
|
// biome-ignore format: auto-generated
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
|
|
5
|
+
// Generated by ArkEnv. DO NOT EDIT DIRECTLY.
|
|
6
|
+
`,b=`
|
|
7
|
+
export default createEnv;
|
|
8
|
+
`;function x(e,t){return`${y}
|
|
13
9
|
import { createEnv as coreCreateEnv } from "@arkenv/nextjs";
|
|
14
|
-
import type { Infer } from "@arkenv/nextjs";
|
|
15
10
|
|
|
16
11
|
export { type } from "@arkenv/nextjs";
|
|
17
12
|
|
|
@@ -25,27 +20,48 @@ export function createEnv<
|
|
|
25
20
|
[K in keyof TClient]: K extends \`NEXT_PUBLIC_\${string}\` ? unknown : never;
|
|
26
21
|
};
|
|
27
22
|
shared?: TShared;
|
|
28
|
-
})
|
|
23
|
+
}) {
|
|
29
24
|
return coreCreateEnv({
|
|
30
25
|
...options,
|
|
31
26
|
runtimeEnv: {
|
|
32
|
-
${
|
|
33
|
-
`)}
|
|
27
|
+
${v(e,t)}
|
|
34
28
|
},
|
|
35
29
|
} as any) as any;
|
|
36
30
|
}
|
|
31
|
+
${b}`}function S(e,t){return`${y}
|
|
32
|
+
import { createEnv as coreCreateEnv } from "@arkenv/nextjs";
|
|
33
|
+
import type { type as at, distill } from "arktype";
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
export default arkenv;
|
|
40
|
-
`}function b(e,t){return`/* eslint-disable */
|
|
41
|
-
// prettier-ignore
|
|
42
|
-
// biome-ignore format: auto-generated
|
|
43
|
-
/**
|
|
44
|
-
* @file env.gen.ts
|
|
45
|
-
* @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.
|
|
46
|
-
* @see https://arkenv.js.org
|
|
47
|
-
*/
|
|
35
|
+
export { type } from "@arkenv/nextjs";
|
|
48
36
|
|
|
37
|
+
export function createEnv<
|
|
38
|
+
const TSchema extends Record<string, unknown> & { runtimeEnv?: never } = {},
|
|
39
|
+
const TExpose extends keyof TSchema = never,
|
|
40
|
+
const TExtends extends readonly unknown[] = [],
|
|
41
|
+
>(
|
|
42
|
+
schema: TSchema,
|
|
43
|
+
options?: {
|
|
44
|
+
/**
|
|
45
|
+
* Custom environment variables to expose to the client bundle.
|
|
46
|
+
* By default, variables prefixed with \`NEXT_PUBLIC_\` and \`NODE_ENV\` are exposed automatically.
|
|
47
|
+
* Use this option to expose custom variables that do not have the \`NEXT_PUBLIC_\` prefix.
|
|
48
|
+
*/
|
|
49
|
+
exposeToClient?: readonly TExpose[];
|
|
50
|
+
extends?: [...TExtends];
|
|
51
|
+
},
|
|
52
|
+
): Readonly<distill.Out<at.infer<TSchema>>> {
|
|
53
|
+
// Types expose the full schema for a great DX on the server; the runtime
|
|
54
|
+
// Proxy from \`@arkenv/nextjs\` enforces the security boundary by throwing
|
|
55
|
+
// when a server-only variable is accessed on the client.
|
|
56
|
+
const env = coreCreateEnv(schema as any, {
|
|
57
|
+
...options,
|
|
58
|
+
runtimeEnv: {
|
|
59
|
+
${v(e,t)}
|
|
60
|
+
},
|
|
61
|
+
} as any);
|
|
62
|
+
return env as unknown as Readonly<distill.Out<at.infer<TSchema>>>;
|
|
63
|
+
}
|
|
64
|
+
${b}`}function C(e,t){return`${y}
|
|
49
65
|
import { createEnv as coreCreateEnv } from "@arkenv/nextjs/client";
|
|
50
66
|
|
|
51
67
|
export { type } from "@arkenv/nextjs/client";
|
|
@@ -64,15 +80,9 @@ export function createEnv<
|
|
|
64
80
|
return coreCreateEnv<TSchema, TExtends>(schema as any, {
|
|
65
81
|
...options,
|
|
66
82
|
runtimeEnv: {
|
|
67
|
-
${
|
|
68
|
-
`)}
|
|
83
|
+
${v(e,t)}
|
|
69
84
|
},
|
|
70
85
|
} as any);
|
|
71
86
|
}
|
|
72
|
-
|
|
73
|
-
const arkenv = createEnv;
|
|
74
|
-
export default arkenv;
|
|
75
|
-
`}function x(e){let t=C(e);return t?v(t):[]}function S(e){let t=w(e);return t?v(t):[]}function C(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===`
|
|
76
|
-
`||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 w(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===`
|
|
77
|
-
`||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}exports.extractClientKeys=x,exports.extractKeys=g,exports.extractSharedKeys=S,exports.runCodegen=h,exports.t=s,exports.withArkEnv=d;
|
|
87
|
+
${b}`}exports.extractClientKeys=u.extractClientKeys,exports.extractKeys=_,exports.extractSharedKeys=u.extractSharedKeys,exports.runCodegen=h,exports.setupArkEnv=p,exports.t=s,exports.withArkEnv=m;
|
|
78
88
|
//# sourceMappingURL=config.cjs.map
|
package/dist/config.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":["path","fs"],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { watch as chokidarWatch } from \"chokidar\";\n\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __arkenv_watcher__: import(\"chokidar\").FSWatcher | undefined;\n}\n\n/**\n * Configuration options for the ArkEnv Next.js integration.\n *\n * @example\n * ```ts\n * const configOptions: ArkEnvConfigOptions = {\n * schemaPath: \"./src/env.ts\",\n * outputPath: \"./src/generated/env.gen.ts\"\n * };\n * ```\n */\nexport type ArkEnvConfigOptions = {\n\t/**\n\t * Specify the path to the schema definition file.\n\t *\n\t * Defaults to searching for `\"src/env.ts\"` or `\"env.ts\"` in the project root.\n\t *\n\t * @default \"src/env.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * schemaPath: \"./src/env.ts\"\n\t * });\n\t * ```\n\t */\n\tschemaPath?: string;\n\n\t/**\n\t * Specify the path where the generated file (`env.gen.ts`) should be written.\n\t *\n\t * Defaults to `\"generated/env.gen.ts\"` in the same directory as the schema file.\n\t *\n\t * @default \"[schemaDirectory]/generated/env.gen.ts\"\n\t * @example\n\t * ```ts\n\t * export default withArkEnv(nextConfig, {\n\t * outputPath: \"./src/generated/env.gen.ts\"\n\t * });\n\t * ```\n\t */\n\toutputPath?: string;\n\n\t/**\n\t * Specify the configuration layout.\n\t *\n\t * - `\"simple\"` (default): A single `env.ts` schema file.\n\t * - `\"strict\"`: A 3-file split schema layout (`env/internal/shared.ts`, `env/client.ts`, `env/server.ts`).\n\t *\n\t * @default \"simple\"\n\t */\n\tlayout?: \"simple\" | \"strict\";\n};\n\n/**\n * Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.\n *\n * @param nextConfig The Next.js configuration object or function\n * @param options Optional configuration paths for schema and output files\n * @returns The Next.js configuration object unchanged\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T {\n\t// 1. Locate the env.ts schema file or strict schema directory\n\tconst schemaPath = options?.schemaPath\n\t\t? path.resolve(options.schemaPath)\n\t\t: findSchemaPath();\n\n\t// Auto-detect layout if not specified\n\tlet exists = false;\n\tif (schemaPath) {\n\t\tif (fs.existsSync(schemaPath)) {\n\t\t\texists = true;\n\t\t} else {\n\t\t\tconst ext = path.extname(schemaPath);\n\t\t\tif (ext) {\n\t\t\t\tconst baseWithoutExt = schemaPath.slice(0, -ext.length);\n\t\t\t\tif (fs.existsSync(baseWithoutExt)) {\n\t\t\t\t\texists = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!schemaPath || !exists) {\n\t\tthrow new Error(\n\t\t\t`[ArkEnv] Could not find schema file at ${\n\t\t\t\toptions?.schemaPath || \"src/env.ts or env.ts\"\n\t\t\t}. Please specify 'schemaPath' in withArkEnv options.`,\n\t\t);\n\t}\n\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\toptions?.layout,\n\t);\n\n\t// 2. Determine outputPath (defaults to generated/env.gen.ts in the same directory as schemaPath/baseDir)\n\tconst defaultOutputDir =\n\t\tresolvedLayout === \"strict\" && baseDir ? baseDir : path.dirname(schemaPath);\n\tconst defaultOutputPath = path.join(\n\t\tdefaultOutputDir,\n\t\t\"generated\",\n\t\t\"env.gen.ts\",\n\t);\n\tconst outputPath = options?.outputPath\n\t\t? path.resolve(options.outputPath)\n\t\t: defaultOutputPath;\n\n\t// 3. Run initial code generation\n\ttry {\n\t\trunCodegen(schemaPath, outputPath, resolvedLayout);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`[ArkEnv] Failed to generate env.gen.ts: ${message}`);\n\t}\n\n\t// 4. Initialize development file watcher if in dev mode\n\tconst isDev =\n\t\tprocess.env.NODE_ENV === \"development\" ||\n\t\tprocess.env.NEXT_PHASE === \"phase-development-server\";\n\tif (isDev) {\n\t\tconst watchPaths =\n\t\t\tresolvedLayout === \"strict\" && baseDir\n\t\t\t\t? [\n\t\t\t\t\t\tpath.join(baseDir, \"internal\", \"shared.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"client.ts\"),\n\t\t\t\t\t\tpath.join(baseDir, \"server.ts\"),\n\t\t\t\t\t].filter(fs.existsSync)\n\t\t\t\t: [schemaPath];\n\t\twatchSchema(watchPaths, outputPath, resolvedLayout);\n\t}\n\n\treturn nextConfig;\n}\n\n/**\n * Find the path to the schema file in the project.\n *\n * @returns The absolute path to the schema file, or null if not found\n */\n/**\n * Resolve the layout (simple vs strict) and the base directory from a schema path.\n *\n * Auto-detects layout when `layoutOption` is not provided. When `layoutOption`\n * is `\"strict\"`, validates that the required split files exist and throws a\n * descriptive error if either is missing.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param layoutOption The explicit layout option, if provided\n * @returns The resolved layout and base directory\n * @throws An error if strict layout files are missing\n */\nfunction resolveLayout(\n\tschemaPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n): { layout: \"simple\" | \"strict\"; baseDir: string } {\n\tconst checkStrict = (dir: string) =>\n\t\tfs.existsSync(path.join(dir, \"internal\", \"shared.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"client.ts\")) &&\n\t\tfs.existsSync(path.join(dir, \"server.ts\"));\n\n\tconst resolveBaseDir = (p: string): string => {\n\t\t// Normalize: if schemaPath has an extension, try the extensionless form as a dir\n\t\tconst ext = path.extname(p);\n\t\tconst baseWithoutExt = ext ? p.slice(0, -ext.length) : p;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory()\n\t\t) {\n\t\t\treturn baseWithoutExt;\n\t\t}\n\t\treturn p;\n\t};\n\n\tif (!layoutOption) {\n\t\t// Auto-detect\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tif (checkStrict(resolved)) {\n\t\t\t\treturn { layout: \"strict\", baseDir: resolved };\n\t\t\t}\n\t\t\treturn { layout: \"simple\", baseDir: resolved };\n\t\t}\n\n\t\t// schemaPath is a file — check surrounding dirs\n\t\tconst parent = path.dirname(schemaPath);\n\t\tconst ext = path.extname(schemaPath);\n\t\tconst baseWithoutExt = ext ? schemaPath.slice(0, -ext.length) : schemaPath;\n\t\tif (\n\t\t\tfs.existsSync(baseWithoutExt) &&\n\t\t\tfs.statSync(baseWithoutExt).isDirectory() &&\n\t\t\tcheckStrict(baseWithoutExt)\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: baseWithoutExt };\n\t\t}\n\t\tif (checkStrict(parent)) {\n\t\t\treturn { layout: \"strict\", baseDir: parent };\n\t\t}\n\t\tif (\n\t\t\tpath.basename(parent) === \"internal\" &&\n\t\t\tcheckStrict(path.dirname(parent))\n\t\t) {\n\t\t\treturn { layout: \"strict\", baseDir: path.dirname(parent) };\n\t\t}\n\t\treturn { layout: \"simple\", baseDir: schemaPath };\n\t}\n\n\tif (layoutOption === \"strict\") {\n\t\t// Resolve baseDir for an explicit strict layout\n\t\tlet baseDir: string;\n\t\tconst resolved = resolveBaseDir(schemaPath);\n\t\tif (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory()) {\n\t\t\tbaseDir = resolved;\n\t\t} else {\n\t\t\tconst parent = path.dirname(schemaPath);\n\t\t\tif (path.basename(parent) === \"internal\") {\n\t\t\t\tbaseDir = path.dirname(parent);\n\t\t\t} else {\n\t\t\t\tbaseDir = parent;\n\t\t\t}\n\t\t}\n\n\t\t// Validate that required split files exist\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\t\tif (!fs.existsSync(clientPath) || !fs.existsSync(sharedPath)) {\n\t\t\tthrow new Error(\n\t\t\t\t`[ArkEnv] Strict layout requires \"${clientPath}\" and \"${sharedPath}\" to exist. ` +\n\t\t\t\t\t`Ensure both files are present or remove the 'layout: \"strict\"' option to let ArkEnv auto-detect.`,\n\t\t\t);\n\t\t}\n\n\t\treturn { layout: \"strict\", baseDir };\n\t}\n\n\t// layoutOption === \"simple\"\n\treturn { layout: \"simple\", baseDir: schemaPath };\n}\n\nfunction findSchemaPath(): string | null {\n\tconst possiblePaths = [\n\t\tpath.join(process.cwd(), \"src\", \"env.ts\"),\n\t\tpath.join(process.cwd(), \"env.ts\"),\n\t];\n\tfor (const p of possiblePaths) {\n\t\tif (fs.existsSync(p)) return p;\n\t}\n\n\tconst possibleDirs = [\n\t\tpath.join(process.cwd(), \"src\", \"env\"),\n\t\tpath.join(process.cwd(), \"env\"),\n\t];\n\tfor (const d of possibleDirs) {\n\t\tif (\n\t\t\tfs.existsSync(d) &&\n\t\t\tfs.existsSync(path.join(d, \"internal\", \"shared.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"client.ts\")) &&\n\t\t\tfs.existsSync(path.join(d, \"server.ts\"))\n\t\t) {\n\t\t\treturn d;\n\t\t}\n\t}\n\treturn null;\n}\n\n/**\n * Watch the schema file for changes and trigger codegen.\n *\n * @param schemaPath The absolute path to the schema file, or an array of paths to watch\n * @param outputPath The absolute path to the generated output file\n * @param layout The resolved layout to pass through to codegen on each change\n */\nfunction watchSchema(\n\tschemaPath: string | string[],\n\toutputPath: string,\n\tlayout?: \"simple\" | \"strict\",\n) {\n\tconst previousWatcher = globalThis.__arkenv_watcher__;\n\tif (previousWatcher && typeof previousWatcher.close === \"function\") {\n\t\tpreviousWatcher.close().catch((err: unknown) => {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\tconsole.error(\n\t\t\t\t`[ArkEnv Watcher] Failed to close previous watcher: ${message}`,\n\t\t\t);\n\t\t});\n\t}\n\n\ttry {\n\t\tconst watcher = chokidarWatch(schemaPath, { ignoreInitial: true });\n\t\tglobalThis.__arkenv_watcher__ = watcher;\n\n\t\twatcher.on(\"change\", () => {\n\t\t\ttry {\n\t\t\t\tconst mainSchemaPath = Array.isArray(schemaPath)\n\t\t\t\t\t? schemaPath[0]\n\t\t\t\t\t: schemaPath;\n\t\t\t\trunCodegen(mainSchemaPath, outputPath, layout);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[ArkEnv Watcher] Failed to regenerate env.gen.ts: ${message}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t} catch (err: unknown) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t// biome-ignore lint/suspicious/noConsole: watcher errors must be logged\n\t\tconsole.error(\n\t\t\t`[ArkEnv Watcher] Failed to start watch on ${schemaPath}: ${message}`,\n\t\t);\n\t}\n}\n\n/**\n * Run code generation to read the schema file and generate the env.gen.ts factory.\n *\n * @param schemaPath The absolute path to the schema file or directory\n * @param outputPath The absolute path to the generated output file\n * @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted\n * @throws An error if strict layout files are missing when `layoutOption` is `\"strict\"`\n */\nexport function runCodegen(\n\tschemaPath: string,\n\toutputPath: string,\n\tlayoutOption?: \"simple\" | \"strict\",\n) {\n\tconst { layout: resolvedLayout, baseDir } = resolveLayout(\n\t\tschemaPath,\n\t\tlayoutOption,\n\t);\n\n\tlet generatedCode = \"\";\n\tif (resolvedLayout === \"strict\") {\n\t\tconst clientPath = path.join(baseDir, \"client.ts\");\n\t\tconst sharedPath = path.join(baseDir, \"internal\", \"shared.ts\");\n\n\t\tconst clientContent = fs.existsSync(clientPath)\n\t\t\t? fs.readFileSync(clientPath, \"utf-8\")\n\t\t\t: \"\";\n\t\tconst sharedContent = fs.existsSync(sharedPath)\n\t\t\t? fs.readFileSync(sharedPath, \"utf-8\")\n\t\t\t: \"\";\n\n\t\tconst clientKeys = extractClientKeys(clientContent);\n\t\tconst sharedKeys = extractSharedKeys(sharedContent);\n\n\t\tgeneratedCode = generateClientFactoryCode(clientKeys, sharedKeys);\n\t} else {\n\t\tconst fileContent = fs.readFileSync(schemaPath, \"utf-8\");\n\t\tconst { clientKeys, sharedKeys } = extractKeys(fileContent);\n\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys);\n\t}\n\n\t// Ensure parent directory exists\n\tconst outputDir = path.dirname(outputPath);\n\tif (!fs.existsSync(outputDir)) {\n\t\tfs.mkdirSync(outputDir, { recursive: true });\n\t}\n\n\t// Write if changed to avoid unnecessary filesystem/watcher triggers\n\tlet shouldWrite = true;\n\tif (fs.existsSync(outputPath)) {\n\t\tconst existingContent = fs.readFileSync(outputPath, \"utf-8\");\n\t\tif (existingContent === generatedCode) {\n\t\t\tshouldWrite = false;\n\t\t}\n\t}\n\n\tif (shouldWrite) {\n\t\tfs.writeFileSync(outputPath, generatedCode, \"utf-8\");\n\t}\n}\n\n/**\n * Statically extract client and shared keys from the schema content.\n *\n * @param content The schema file string content\n * @returns An object containing the extracted client and shared keys\n */\nexport function extractKeys(content: string): {\n\tclientKeys: string[];\n\tsharedKeys: string[];\n} {\n\tconst clientKeys: string[] = [];\n\tconst sharedKeys: string[] = [];\n\n\t// Extract client block\n\tconst clientBlock = extractBlock(content, \"client\");\n\tif (clientBlock) {\n\t\tclientKeys.push(...parseBlockKeys(clientBlock));\n\t}\n\n\t// Extract shared block\n\tconst sharedBlock = extractBlock(content, \"shared\");\n\tif (sharedBlock) {\n\t\tsharedKeys.push(...parseBlockKeys(sharedBlock));\n\t}\n\n\treturn { clientKeys, sharedKeys };\n}\n\n/**\n * Extract a specific block from the schema content by name.\n *\n * @param content The schema file string content\n * @param blockName The name of the block to extract (e.g., 'client' or 'shared')\n * @returns The contents of the block, or null if not found\n */\nfunction extractBlock(content: string, blockName: string): string | null {\n\t// Find \"\\bblockName\\s*:\\s*{\" or \"\\bblockName\\s*:\\s*type({\"\n\tconst regex = new RegExp(\n\t\t`\\\\b${blockName}\\\\s*:\\\\s*(?:[a-zA-Z0-9_$.]+\\\\s*\\\\(\\\\s*)?\\\\{`,\n\t\t\"g\",\n\t);\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Parse environment variable keys from a block's content.\n *\n * @param blockContent The raw content of the block\n * @returns An array of parsed environment variable keys\n */\nfunction parseBlockKeys(blockContent: string): string[] {\n\tconst keys: string[] = [];\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\tlet currentToken = \"\";\n\tlet lastStringContent = \"\";\n\tlet braceDepth = 0;\n\n\tfor (let i = 0; i < blockContent.length; i++) {\n\t\tconst char = blockContent[i];\n\t\tconst nextChar = blockContent[i + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && blockContent[i - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t\tlastStringContent = currentToken;\n\t\t\t\tcurrentToken = \"\";\n\t\t\t} else {\n\t\t\t\tcurrentToken += char;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Start comments/strings\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tcurrentToken = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceDepth++;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"}\") {\n\t\t\tbraceDepth--;\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \":\") {\n\t\t\tif (braceDepth === 0) {\n\t\t\t\tconst key = currentToken.trim() || lastStringContent.trim();\n\t\t\t\tif (key) {\n\t\t\t\t\tkeys.push(key);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (/[a-zA-Z0-9_$]/.test(char)) {\n\t\t\tcurrentToken += char;\n\t\t} else if (char === \",\" || char === \"\\n\" || char === \"\\r\") {\n\t\t\tcurrentToken = \"\";\n\t\t\tlastStringContent = \"\";\n\t\t}\n\t}\n\n\treturn keys;\n}\n\n/**\n * Generate the TypeScript factory code for the tailored createEnv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @returns The generated TypeScript source code string\n */\nfunction generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs\";\nimport type { Infer } from \"@arkenv/nextjs\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function createEnv<\n\tconst TServer extends Record<string, any> = {},\n\tconst TClient extends Record<string, any> = {},\n\tconst TShared extends Record<string, any> = {},\n>(options: {\n\tserver?: TServer;\n\tclient?: TClient & {\n\t\t[K in keyof TClient]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t};\n\tshared?: TShared;\n}): Readonly<Infer<TServer & TClient & TShared>> {\n\treturn coreCreateEnv({\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any) as any;\n}\n\nconst arkenv = createEnv;\nexport default arkenv;\n`;\n}\n\n/**\n * Generate the TypeScript factory code for the strict-layout `createEnv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @returns The generated TypeScript source code string\n */\nfunction generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst allKeys = Array.from(new Set([...clientKeys, ...sharedKeys]));\n\tconst runtimeEnvLines = allKeys\n\t\t.map((key) => `\\t\\t\\t${key}: process.env.${key},`)\n\t\t.join(\"\\n\");\n\n\treturn `/* eslint-disable */\n// prettier-ignore\n// biome-ignore format: auto-generated\n/**\n * @file env.gen.ts\n * @note This file is auto-generated by ArkEnv. DO NOT EDIT DIRECTLY.\n * @see https://arkenv.js.org\n */\n\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs/client\";\n\nexport { type } from \"@arkenv/nextjs/client\";\n\nexport function createEnv<\n\tconst TSchema extends Record<string, any> = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema & {\n\t\t[K in keyof TSchema]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t},\n\toptions?: {\n\t\textends?: [...TExtends];\n\t},\n) {\n\treturn coreCreateEnv<TSchema, TExtends>(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);\n}\n\nconst arkenv = createEnv;\nexport default arkenv;\n`;\n}\n\n/**\n * Extract env var keys from a strict-layout `client.ts` file.\n *\n * Locates the first `arkenv({...})` call and delegates to `parseBlockKeys`\n * to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `client.ts`\n * @returns An array of env var key names found in the client schema\n */\nexport function extractClientKeys(content: string): string[] {\n\tconst block = extractClientBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract env var keys from a strict-layout `internal/shared.ts` file.\n *\n * Locates the `SharedSchema = ...({...})` assignment and delegates to\n * `parseBlockKeys` to enumerate the keys defined in the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns An array of env var key names found in the shared schema\n */\nexport function extractSharedKeys(content: string): string[] {\n\tconst block = extractSharedBlock(content);\n\treturn block ? parseBlockKeys(block) : [];\n}\n\n/**\n * Extract the schema object body from a strict-layout `client.ts` file.\n *\n * Matches the first `arkenv(...)` call, then performs brace-balanced\n * traversal while respecting strings and comments to find the boundaries\n * of the first argument object.\n *\n * @param content The source text of `client.ts`\n * @returns The raw text inside the first `{...}` argument, or `null` if not found\n */\nfunction extractClientBlock(content: string): string | null {\n\tconst regex = /\\barkenv\\s*\\(\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n\n/**\n * Extract the schema object body from a strict-layout `internal/shared.ts` file.\n *\n * Matches the `SharedSchema = ...({...})` assignment, then performs\n * brace-balanced traversal while respecting strings and comments to find\n * the boundaries of the schema object.\n *\n * @param content The source text of `internal/shared.ts`\n * @returns The raw text inside the `{...}` schema object, or `null` if not found\n */\nfunction extractSharedBlock(content: string): string | null {\n\tconst regex = /\\bSharedSchema\\s*=\\s*(?:[a-zA-Z0-9_$.]+\\s*\\(\\s*)*\\{/g;\n\tconst match = regex.exec(content);\n\tif (!match) return null;\n\n\tconst startIndex = regex.lastIndex;\n\tlet braceCount = 1;\n\tlet index = startIndex;\n\tlet inString: string | null = null;\n\tlet inComment: \"single\" | \"multi\" | null = null;\n\n\twhile (index < content.length && braceCount > 0) {\n\t\tconst char = content[index];\n\t\tconst nextChar = content[index + 1];\n\n\t\tif (inComment === \"single\") {\n\t\t\tif (char === \"\\n\" || char === \"\\r\") inComment = null;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inComment === \"multi\") {\n\t\t\tif (char === \"*\" && nextChar === \"/\") {\n\t\t\t\tinComment = null;\n\t\t\t\tindex += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (char === inString && content[index - 1] !== \"\\\\\") {\n\t\t\t\tinString = null;\n\t\t\t}\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"/\" && nextChar === \"/\") {\n\t\t\tinComment = \"single\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"/\" && nextChar === \"*\") {\n\t\t\tinComment = \"multi\";\n\t\t\tindex += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"'\" || char === '\"' || char === \"`\") {\n\t\t\tinString = char;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === \"{\") {\n\t\t\tbraceCount++;\n\t\t} else if (char === \"}\") {\n\t\t\tbraceCount--;\n\t\t}\n\t\tindex++;\n\t}\n\n\tif (braceCount === 0) {\n\t\treturn content.slice(startIndex, index - 1);\n\t}\n\n\treturn null;\n}\n"],"mappings":"ioBAsEA,SAAgB,EAAc,EAAe,EAAkC,CAE9E,IAAM,EAAa,GAAS,WACzBA,EAAAA,QAAK,QAAQ,EAAQ,WAAW,CAChC,GAAgB,CAGf,EAAS,GACb,GAAI,EACH,GAAIC,EAAAA,QAAG,WAAW,EAAW,CAC5B,EAAS,OACH,CACN,IAAM,EAAMD,EAAAA,QAAK,QAAQ,EAAW,CACpC,GAAI,EAAK,CACR,IAAM,EAAiB,EAAW,MAAM,EAAG,C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ACrB,EAAa,EACb,EAAQ,EACR,EAA0B,KAC1B,EAAuC,KAE3C,KAAO,EAAQ,EAAQ,QAAU,EAAa,GAAG,CAChD,IAAM,EAAO,EAAQ,GACf,EAAW,EAAQ,EAAQ,GAEjC,GAAI,IAAc,SAAU,EACvB,IAAS;GAAQ,IAAS,QAAM,EAAY,MAChD,IACA,SAED,GAAI,IAAc,QAAS,CAC1B,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,KACZ,GAAS,EACT,SAED,IACA,SAGD,GAAI,EAAU,CACT,IAAS,GAAY,EAAQ,EAAQ,KAAO,OAC/C,EAAW,MAEZ,IACA,SAGD,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,SACZ,GAAS,EACT,SAED,GAAI,IAAS,KAAO,IAAa,IAAK,CACrC,EAAY,QACZ,GAAS,EACT,SAED,GAAI,IAAS,KAAO,IAAS,KAAO,IAAS,IAAK,CACjD,EAAW,EACX,IACA,SAGG,IAAS,IACZ,IACU,IAAS,KACnB,IAED,IAOD,OAJI,IAAe,EACX,EAAQ,MAAM,EAAY,EAAQ,EAAE,CAGrC"}
|
|
1
|
+
{"version":3,"file":"config.cjs","names":["path","fs"],"sources":["../src/config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n\textractBlock,\n\textractClientKeys,\n\textractSharedKeys,\n\tfindSchemaPath,\n\tparseBlockKeys,\n\tresolveLayout,\n\twatchSchema,\n} from \"@arkenv/build\";\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\n/**\n * Run ArkEnv codegen and setup without wrapping nextConfig.\n *\n * @param options Optional configuration paths for schema and output files\n * @throws An error if the schema file cannot be found or if code generation fails\n */\nexport function setupArkEnv(options?: ArkEnvConfigOptions): 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\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, () => {\n\t\t\trunCodegen(schemaPath, outputPath, resolvedLayout);\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 * @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) {\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 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, isLegacy } = extractKeys(fileContent);\n\t\tif (isLegacy) {\n\t\t\tgeneratedCode = generateFactoryCode(clientKeys, sharedKeys);\n\t\t} else {\n\t\t\tgeneratedCode = generateFlatFactoryCode(clientKeys, sharedKeys);\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 createEnv;\n`;\n\n/**\n * Generate the TypeScript factory code for the tailored createEnv helper.\n *\n * @param clientKeys The client environment variable keys\n * @param sharedKeys The shared environment variable keys\n * @returns The generated TypeScript source code string\n */\nfunction generateFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\n\treturn `${GENERATED_HEADER}\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function createEnv<\n\tconst TServer extends Record<string, any> = {},\n\tconst TClient extends Record<string, any> = {},\n\tconst TShared extends Record<string, any> = {},\n>(options: {\n\tserver?: TServer;\n\tclient?: TClient & {\n\t\t[K in keyof TClient]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t};\n\tshared?: TShared;\n}) {\n\treturn coreCreateEnv({\n\t\t...options,\n\t\truntimeEnv: {\n${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 createEnv 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): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\n\treturn `${GENERATED_HEADER}\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs\";\nimport type { type as at, distill } from \"arktype\";\n\nexport { type } from \"@arkenv/nextjs\";\n\nexport function createEnv<\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): Readonly<distill.Out<at.infer<TSchema>>> {\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 = coreCreateEnv(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);\n\treturn env as unknown as Readonly<distill.Out<at.infer<TSchema>>>;\n}\n${GENERATED_FOOTER}`;\n}\n\n/**\n * Generate the TypeScript factory code for the strict-layout `createEnv` helper.\n *\n * Unlike `generateFactoryCode`, this variant imports from `@arkenv/nextjs/client`\n * and exposes a positional-schema signature suited for split-file projects.\n *\n * @param clientKeys The env var keys extracted from `client.ts`\n * @param sharedKeys The env var keys extracted from `internal/shared.ts`\n * @returns The generated TypeScript source code string\n */\nfunction generateClientFactoryCode(\n\tclientKeys: string[],\n\tsharedKeys: string[],\n): string {\n\tconst runtimeEnvLines = generateRuntimeEnvLines(clientKeys, sharedKeys);\n\n\treturn `${GENERATED_HEADER}\nimport { createEnv as coreCreateEnv } from \"@arkenv/nextjs/client\";\n\nexport { type } from \"@arkenv/nextjs/client\";\n\nexport function createEnv<\n\tconst TSchema extends Record<string, any> = {},\n\tconst TExtends extends readonly unknown[] = [],\n>(\n\tschema: TSchema & {\n\t\t[K in keyof TSchema]: K extends \\`NEXT_PUBLIC_\\${string}\\` ? unknown : never;\n\t},\n\toptions?: {\n\t\textends?: [...TExtends];\n\t},\n) {\n\treturn coreCreateEnv<TSchema, TExtends>(schema as any, {\n\t\t...options,\n\t\truntimeEnv: {\n${runtimeEnvLines}\n\t\t},\n\t} as any);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AWzB,SAAS,EACR,EACA,EACS,CAGT,MAAO,GAAG,EAAiB;;;;;;;;;;;;;;;;;;;EAFH,EAAwB,EAAY,EAqB5C,CAAC;;;;EAIhB,IAoBF,SAAS,EACR,EACA,EACS,CAGT,MAAO,GAAG,EAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAFH,EAAwB,EAAY,EA8B5C,CAAC;;;;;EAKhB,IAaF,SAAS,EACR,EACA,EACS,CAGT,MAAO,GAAG,EAAiB;;;;;;;;;;;;;;;;;;;EAFH,EAAwB,EAAY,EAqB5C,CAAC;;;;EAIhB"}
|
package/dist/config.d.cts
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,20 @@ 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";
|
|
56
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
56
|
+
*
|
|
57
|
+
* @param options Optional configuration paths for schema and output files
|
|
58
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
59
|
+
*/
|
|
60
|
+
declare function setupArkEnv(options?: ArkEnvConfigOptions): void;
|
|
57
61
|
/**
|
|
58
62
|
* Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.
|
|
59
63
|
*
|
|
@@ -71,7 +75,7 @@ declare function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
|
71
75
|
* @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted
|
|
72
76
|
* @throws An error if strict layout files are missing when `layoutOption` is `"strict"`
|
|
73
77
|
*/
|
|
74
|
-
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: "
|
|
78
|
+
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: ArkEnvConfigOptions["layout"]): void;
|
|
75
79
|
/**
|
|
76
80
|
* Statically extract client and shared keys from the schema content.
|
|
77
81
|
*
|
|
@@ -81,27 +85,8 @@ declare function runCodegen(schemaPath: string, outputPath: string, layoutOption
|
|
|
81
85
|
declare function extractKeys(content: string): {
|
|
82
86
|
clientKeys: string[];
|
|
83
87
|
sharedKeys: string[];
|
|
88
|
+
isLegacy?: boolean;
|
|
84
89
|
};
|
|
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
90
|
//#endregion
|
|
106
|
-
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, withArkEnv };
|
|
91
|
+
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, setupArkEnv, withArkEnv };
|
|
107
92
|
//# sourceMappingURL=config.d.cts.map
|
package/dist/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;;AA6CA;;;;;;;;;AAoDA;KApDY,mBAAA;;;;AAwIZ;;;;;;;;;;EA1HC,UAAA;EA0HsD;;;;;AAavD;;;;;;;;EAxHC,UAAA;EA2H4C;AAyK7C;;;;;;;EA1RC,MAAA,qBA6RQ;AAAA;;;;;;;iBAhRO,WAAA,CAAY,OAAA,GAAU,mBAAA;;;;;;;;;iBAoFtB,UAAA,GAAA,CAAc,UAAA,EAAY,CAAA,EAAG,OAAA,GAAU,mBAAA,GAAsB,CAAA;;;;;;;;;iBAa7D,UAAA,CACf,UAAA,UACA,UAAA,UACA,YAAA,GAAe,mBAAA;;;;;;;iBAyKA,WAAA,CAAY,OAAA;EAC3B,UAAA;EACA,UAAA;EACA,QAAA;AAAA"}
|
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,20 @@ 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";
|
|
56
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Run ArkEnv codegen and setup without wrapping nextConfig.
|
|
56
|
+
*
|
|
57
|
+
* @param options Optional configuration paths for schema and output files
|
|
58
|
+
* @throws An error if the schema file cannot be found or if code generation fails
|
|
59
|
+
*/
|
|
60
|
+
declare function setupArkEnv(options?: ArkEnvConfigOptions): void;
|
|
57
61
|
/**
|
|
58
62
|
* Wrap a Next.js configuration object to automatically generate the `runtimeEnv` block in `env.gen.ts`.
|
|
59
63
|
*
|
|
@@ -71,7 +75,7 @@ declare function withArkEnv<T>(nextConfig: T, options?: ArkEnvConfigOptions): T;
|
|
|
71
75
|
* @param layoutOption The explicit layout to use; auto-detected from the filesystem when omitted
|
|
72
76
|
* @throws An error if strict layout files are missing when `layoutOption` is `"strict"`
|
|
73
77
|
*/
|
|
74
|
-
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: "
|
|
78
|
+
declare function runCodegen(schemaPath: string, outputPath: string, layoutOption?: ArkEnvConfigOptions["layout"]): void;
|
|
75
79
|
/**
|
|
76
80
|
* Statically extract client and shared keys from the schema content.
|
|
77
81
|
*
|
|
@@ -81,27 +85,8 @@ declare function runCodegen(schemaPath: string, outputPath: string, layoutOption
|
|
|
81
85
|
declare function extractKeys(content: string): {
|
|
82
86
|
clientKeys: string[];
|
|
83
87
|
sharedKeys: string[];
|
|
88
|
+
isLegacy?: boolean;
|
|
84
89
|
};
|
|
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
90
|
//#endregion
|
|
106
|
-
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, withArkEnv };
|
|
91
|
+
export { ArkEnvConfigOptions, extractClientKeys, extractKeys, extractSharedKeys, runCodegen, setupArkEnv, withArkEnv };
|
|
107
92
|
//# 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":";;;;AA6CA;;;;;;;;;AAoDA;KApDY,mBAAA;;;;AAwIZ;;;;;;;;;;EA1HC,UAAA;EA0HsD;;;;;AAavD;;;;;;;;EAxHC,UAAA;EA2H4C;AAyK7C;;;;;;;EA1RC,MAAA,qBA6RQ;AAAA;;;;;;;iBAhRO,WAAA,CAAY,OAAA,GAAU,mBAAA;;;;;;;;;iBAoFtB,UAAA,GAAA,CAAc,UAAA,EAAY,CAAA,EAAG,OAAA,GAAU,mBAAA,GAAsB,CAAA;;;;;;;;;iBAa7D,UAAA,CACf,UAAA,UACA,UAAA,UACA,YAAA,GAAe,mBAAA;;;;;;;iBAyKA,WAAA,CAAY,OAAA;EAC3B,UAAA;EACA,UAAA;EACA,QAAA;AAAA"}
|