import { Env, EnvActions, EnvFactoryOpts } from "../sys-env.js"; let once: BrowserEnvActions | undefined = undefined; export class BrowserEnvActions implements EnvActions { readonly env: Map = new Map(); readonly opts: Partial; static new(opts: Partial): EnvActions { once = once ?? new BrowserEnvActions(opts); return once; } private constructor(opts: Partial) { this.opts = opts; } get(key: string): string | undefined { return this.env.get(key); } set(key: string, value?: string): void { if (value) { this.env.set(key, value); } } delete(key: string): void { this.env.delete(key); } keys(): string[] { return Array.from(this.env.keys()); } active(): boolean { return true; // that should work on every runtime } register(env: Env): Env { const sym = Symbol.for(this.opts.symbol || "CP_ENV"); const browser = globalThis as unknown as Record; browser[sym] = env; return env; } }