UNPKG

@adopture/next

Version:

Next.js SDK for Adopture feature adoption tracking with SSR support

2 lines 1.36 kB
'use strict';var zod=require('zod');var s=zod.z.object({projectId:zod.z.string().uuid(),projectName:zod.z.string().min(1),apiKey:zod.z.string().regex(/^ad_(live|test)_[a-zA-Z0-9]+$/),environment:zod.z.enum(["live","test"]),apiUrl:zod.z.string().url()});async function d(e){if(typeof window<"u")return null;try{let{promises:n}=await import('fs'),{join:a}=await import('path'),o=a(e||process.cwd(),".adopture.config.json"),i=await n.readFile(o,"utf-8"),r=JSON.parse(i),p=s.safeParse(r);return p.success?p.data:(console.warn("[ADOPTURE] Invalid .adopture.config.json file:",p.error.message),null)}catch(n){return n?.code!=="ENOENT"&&console.warn("[ADOPTURE] Failed to load .adopture.config.json:",n),null}}function f(){if(typeof window>"u")return null;try{let e=window.__ADOPTURE_CONFIG__;if(e&&typeof e=="object")return e}catch{}return null}function l(e){return {apiKey:e.apiKey,apiUrl:e.apiUrl,projectId:e.projectId,environment:e.environment}}function c(e){return {apiKey:e.apiKey,apiUrl:e.apiUrl,projectId:e.projectId,environment:e.environment}}function g(e,n,a){let o={...e};return n&&Object.entries(n).forEach(([i,r])=>{r!=null&&(o[i]=r);}),a&&Object.entries(a).forEach(([i,r])=>{r!=null&&(o[i]=r);}),o}exports.a=s;exports.b=d;exports.c=f;exports.d=l;exports.e=c;exports.f=g;//# sourceMappingURL=chunk-2N3CGLIH.js.map //# sourceMappingURL=chunk-2N3CGLIH.js.map