UNPKG

@varlock/astro-integration

Version:

Astro integration to use varlock for .env file loading - adds validation, type-safety, and extra security features

52 lines 2.37 kB
import "varlock"; import { AstroIntegration } from "astro"; //#region ../vite/dist/index.d.mts interface VarlockVitePluginOptions { /** controls if/how varlock init code is injected into the built SSR application code */ ssrInjectMode?: 'auto-load' | 'init-only' | 'resolved-env'; /** extra code lines to inject at the SSR entry point, before varlock init calls */ ssrEntryCode?: Array<string>; /** set to true for edge runtimes that don't have node:http (skips patchGlobalServerResponse) */ ssrEdgeRuntime?: boolean; /** additional virtual module IDs to treat as entry points (e.g., '\0virtual:cloudflare/worker-entry') */ ssrEntryModuleIds?: Array<string>; /** override integration identity for CLI telemetry (used by composed integrations like Astro) */ integrationTelemetry?: { name: string; version: string; }; /** * set by composed integrations (e.g. `@varlock/cloudflare-integration`, the * Astro Cloudflare adapter branch) when the CF runtime env loader has been * injected via `ssrEntryCode`. Used to reject `ssrInjectMode: 'resolved-env'` * as redundant — the loader already hydrates env from Cloudflare bindings. */ isCloudflareTarget?: boolean; /** * directory varlock should load `.env` files from. Defaults to vite's `root`. * Set by integrations whose framework points vite's `root` at a source * subdirectory rather than the project root — e.g. Nuxt 4, where `root` is * the `app/` srcDir but the env files live one level up. */ rootDir?: string; } //#endregion //#region src/index.d.ts interface VarlockAstroPublicDynamicEndpointOptions { /** Route path for public dynamic values */ path?: string; } interface VarlockAstroIntegrationOptions extends VarlockVitePluginOptions { /** * Inject a route that returns `getPublicDynamicEnv()`. * - `undefined`: auto (enabled only when dynamic+public config exists) * - `true`: always enabled at `DEFAULT_PUBLIC_DYNAMIC_ENDPOINT` * - `false`: disabled * - object: enabled with custom options */ publicDynamicEndpoint?: boolean | VarlockAstroPublicDynamicEndpointOptions; } declare function varlockAstroIntegration(integrationOptions?: VarlockAstroIntegrationOptions): AstroIntegration; //#endregion export { VarlockAstroIntegrationOptions, varlockAstroIntegration as default }; //# sourceMappingURL=index.d.mts.map