@donotdev/core 0.0.33 → 0.0.35

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/empty.js CHANGED
@@ -1,5 +1,19 @@
1
1
  /**
2
2
  * @fileoverview Empty placeholder for optional features
3
- * @description Used by Next.js/Turbopack resolution to alias missing optional features
3
+ * @description Used by Vite/Next.js/Turbopack resolution to alias missing optional features.
4
+ * Returns a Proxy that silently absorbs any property access or function call,
5
+ * preventing runtime errors when consumer code tries to use missing optional deps.
4
6
  */
5
- export default {};
7
+ const handler = {
8
+ get(_, prop) {
9
+ // Support Promise-like: import('shiki').then(m => m.highlight(...)) — no-op
10
+ if (prop === 'then') return undefined;
11
+ return noop;
12
+ },
13
+ apply() {
14
+ return noop;
15
+ },
16
+ };
17
+ const noop = new Proxy(function () {}, handler);
18
+ export default noop;
19
+ export { noop as __esModule };
@@ -1,20 +1,20 @@
1
- import F from"node:fs";import k from"node:path";import{fileURLToPath as oe}from"node:url";var ne=oe(import.meta.url),be=k.dirname(ne);function $(){let a=process.cwd(),e=10;for(let t=0;t<e;t++){let o=k.join(a,"package.json");if(F.existsSync(o))try{let s=JSON.parse(F.readFileSync(o,"utf8")),r=s.workspaces&&Array.isArray(s.workspaces);if(r&&s.workspaces.some(i=>i==="packages/**"||i.startsWith("packages/"))&&(F.existsSync(k.join(a,"packages","core"))||F.existsSync(k.join(a,"packages","functions"))))return{type:"dndev",root:a};if(r&&s.workspaces.some(i=>i.includes("dndev/packages"))){let u=s.workspaces.find(m=>m.includes("dndev/packages")).replace(/\/packages.*$/,""),f=k.resolve(a,u);if(F.existsSync(k.join(f,"packages","core")))return{type:"dndev",root:f}}}catch{}let n=k.dirname(a);if(n===a)break;a=n}return{type:"npm",root:process.cwd()}}function ie(a){return a.type==="dndev"?a.root:null}function H(a){let e={};if(a.type==="dndev"){let t=ie(a);t&&(e["@donotdev/types"]=k.join(t,"packages","core","types","src"),e["@donotdev/functions"]=k.join(t,"packages","functions","src"),e["@donotdev/utils"]=k.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=k.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=k.join(t,"packages","core"))}return e}import*as h from"node:fs";import"node:fs";import{createRequire as ce}from"node:module";import{resolve as j,join as b,dirname as w,relative as K,normalize as le,sep as q,extname as ue}from"node:path";import{fileURLToPath as pe}from"node:url";import fe from"fast-glob";var I={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},E={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${I.SOURCE_EAGER}/*_*.json`],lazy:[`${I.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]};var Y={base:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore}};function V(a,e=null){let t=E[a];if(!t)throw new Error(`Unknown pattern type: ${a}`);return e&&t.framework?{...t,framework:t.framework.map(o=>`${e}/${o}`)}:t}function J(a){return Y[a]||Y.base}var S={getGlobOptionsFor:J||void 0,SCAN_PATTERNS:E||void 0,getPatternsFor:V||void 0,I18N_PATHS:I||void 0},v={error:(a,e)=>{},warn:(a,e)=>{},info:a=>{}};function X(a,e){return a().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var Z={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},D=class a{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return a._instance||(a._instance=new a(e)),a._instance}static _reset(){a._instance=null}constructor(e={}){if(a._instance)return a._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,a._instance=this}normalizePath(e){if(!e)return"";try{return le(e).split(q).join("/")}catch{return String(e).split(q).join("/")}}getRelativePath(e){let t=this.getAppRoot(),o=K(t,e);return this.normalizePath(o)}getBasename(e){if(!e)return"";let o=this.normalizePath(e).split("/");return o[o.length-1]||""}getDirname(e){return e?this.normalizePath(w(e)):""}resolvePackage(e,t=null){try{let o=t||this.getAppRoot(),s=ce(b(o,"package.json")).resolve(e);return this.normalizePath(s)}catch{return null}}resolveFrameworkPackage(e,t=null){let o=this.resolvePackage(`${e}/package.json`,t);if(o)return this.getDirname(o);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let r=e.replace("@donotdev/",""),c=this.resolveRepoPath(`packages/${r}`);if(this.pathExists(c))return c;if(["auth","billing","crud","oauth"].includes(r)){let l=this.resolveRepoPath(`packages/features/${r}`);if(this.pathExists(l))return l}if(r==="firebase"){let l=this.resolveRepoPath(`packages/providers/${r}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(n))return n;let s=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(s)?s:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),o=j(t,e);return this.normalizePath(o)}resolveRepoPath(e){let t=this.getRepoRoot(),o=this.normalizePath(e),n=j(t,o);return this.normalizePath(n)}resolvePath(e,t){let o=this.normalizePath(t),n=this.normalizePath(e),s=j(o,n);return this.normalizePath(s)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=h.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:ue(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return await h.promises.readFile(e);let r=await h.promises.readFile(e,n),c=this.stripBom(r);return s==="json"?JSON.parse(c):c}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}readSync(e,t={}){let{format:o="auto",encoding:n="utf8"}=t,s=this._detectFormat(e,o);try{if(s==="buffer")return h.readFileSync(e);let r=h.readFileSync(e,n),c=this.stripBom(r);return s==="json"?JSON.parse(c):c}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}async write(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:c=!1}=o,l=this.normalizePath(e),p=this.normalizePath(w(l)),i=this.pathExists(l);if(i&&!s)return c&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{await h.promises.mkdir(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return await X(async()=>(Buffer.isBuffer(f)?await h.promises.writeFile(l,f):await h.promises.writeFile(l,f,"utf8"),c&&v.info(`${i?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,o={}){let{format:n="auto",overwrite:s=!1,dryRun:r=!1,verbose:c=!1}=o,l=this.normalizePath(e),p=this.normalizePath(w(l)),i=this.pathExists(l);if(i&&!s)return c&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{h.mkdirSync(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return Buffer.isBuffer(f)?h.writeFileSync(l,f):h.writeFileSync(l,f,"utf8"),c&&v.info(`${i?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,c=this.normalizePath(t),l=this.pathExists(c);if(l&&!n)return r&&v.info(`Skipping existing file: ${c}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${c}`),!0;let p=this.normalizePath(w(c));try{await h.promises.mkdir(p,{recursive:!0})}catch(i){if(i?.code!=="EEXIST")throw i}try{return await X(async()=>(await h.promises.copyFile(e,c),r&&v.info(`${l?"Updated":"Created"} file: ${c}`),!0),`Failed to copy file from ${e} to ${c}`)}catch{return!1}}copySync(e,t,o={}){let{overwrite:n=!1,dryRun:s=!1,verbose:r=!1}=o,c=this.normalizePath(t),l=this.pathExists(c);if(l&&!n)return r&&v.info(`Skipping existing file: ${c}`),!1;if(s)return v.info(`[DRY RUN] Would copy file: ${c}`),!0;let p=this.normalizePath(w(c));try{h.mkdirSync(p,{recursive:!0})}catch(i){if(i?.code!=="EEXIST")throw i}try{return h.copyFileSync(e,c),r&&v.info(`${l?"Updated":"Created"} file: ${c}`),!0}catch{return!1}}pathExists(e,t=!1){try{return h.existsSync(e)}catch(o){return t||v.error(`Error checking path existence: ${e}`,o),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return h.existsSync(t)||h.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return h.readdirSync(e,t)}catch(o){return this.options.debug&&v.warn(`Failed to read directory: ${e}`,o),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return h.statSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to stat file: ${e}`,t),null}}lstatSync(e){try{return h.lstatSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await h.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{h.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await h.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){h.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return h.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=b(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(j(e)),o=this.getAppRoot(),n=K(o,t),s=this.normalizePath(n);return!s.startsWith("../")&&!s.startsWith("/")}async findFiles(e,t,o={}){let n=this.normalizePath(b(e,t)),s=this.getAppRoot(),r=this.normalizePath(s),c=n.startsWith(r)?n.slice(r.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:S.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([c],{...l,...o})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=S.I18N_PATHS;if(!t)return null;let o=e.replace(t.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let s=this.normalizePath(b(n,t.PUBLISHED_ROOT,o)),r=s.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),s}async _globWithNormalization(e,t){return(await fe(e,t)).map(n=>{let s=typeof n=="string"?n:n.path;return this.normalizePath(s)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let o=[...e.framework,...e.consumer];for(let i of o)if(typeof i!="string"||i.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),s=S.getGlobOptionsFor?S.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(n),c=e.framework.map(i=>{let u=this.normalizePath(i);return u.startsWith(r)?u.slice(r.length+1):u}),l=e.consumer.map(i=>{let u=this.normalizePath(i);return u.startsWith(r)?u.slice(r.length+1):u}),p={...s,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let i=c.length>0?await this._globWithNormalization(c,p):[],u=await this._globWithNormalization(l,p);return{frameworkFiles:i,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!S.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),o=this.getRepoRoot();if(e==="i18n"&&(!t||t===o))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${o}). Ensure configResolved hook has run before discovery.`);let n=S.getPatternsFor(e),s=this.isMonorepo();if(e==="i18n"){let l=n,p={eager:l.eager.map(i=>i.startsWith("!")?"!"+this.resolveAppPath(i.slice(1)):this.resolveAppPath(i)),lazy:l.lazy.map(i=>i.startsWith("!")?"!"+this.resolveAppPath(i.slice(1)):this.resolveAppPath(i)),framework:{eager:s?(l.framework?.eager||[]).map(i=>this.resolveRepoPath(i)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(i=>this._resolveFrameworkI18nPattern(i))).then(i=>i.filter(Boolean)),lazy:s?(l.framework?.lazy||[]).map(i=>this.resolveRepoPath(i)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(i=>this._resolveFrameworkI18nPattern(i))).then(i=>i.filter(Boolean))},all:[]};return p.all=[...p.eager,...p.lazy,...p.framework.eager,...p.framework.lazy],p}let r=n,c={framework:s?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return c.all=[...c.consumer,...c.framework],c}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let o=w(pe(import.meta.url));return this.normalizePath(b(o,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),o=0,n=this.options.maxLevels;for(;o<n;){let s=this.normalizePath(b(t,Z.TOOLING)),r=this.normalizePath(b(t,Z.CORE));if(this.pathExists(s)&&this.pathExists(r))return t;let c=b(t,"apps");if(this.pathExists(c)&&this.statSync(c)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(b(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(w(t))===t)return t;let p=this.normalizePath(w(t));if(p===t)break;t=p,o++}return this.normalizePath(e)}};function T(a={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",workspace:r,bundleWorkspaceDeps:c=!1,importFramework:l=!1,external:p=!1,...i}=a,u=D.getInstance(),f=H(r),m={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:o,sourcemap:n,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...i};c&&Object.keys(f).length>0&&(m.alias=Object.fromEntries(Object.entries(f).map(([y,d])=>[y,u.normalizePath(d)]))),m.mainFields=["module","main"],m.conditions=["import","module","node"];let A=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],O=[];if(c)try{let y=r?.root||process.cwd(),d=process.cwd(),g=10;for(let P=0;P<g;P++){let W=u.normalizePath(`${d}/package.json`);if(u.pathExists(W)){let x=u.readSync(W,{format:"json"});if(x&&Array.isArray(x.workspaces)){y=u.normalizePath(d);for(let R of x.workspaces)R==="apps/*"||R==="functions"||!R.includes("*")&&!R.includes("/")&&O.push(R);break}}let z=u.getDirname(d);if(z===d)break;d=z}}catch{}let L={name:"external-node-modules",setup(y){y.onResolve({filter:/^firebase($|\/)/},d=>{if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return null;let g;if(r?.type==="dndev"&&r.root)g=u.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let P=import.meta.url,z=new URL(P).pathname.replace(/^\/([A-Z]:)/i,"$1"),x=u.getDirname(z);g=u.normalizePath(`${x}/firebase-stub.js`)}return{path:g}}),y.onResolve({filter:/.*/},d=>{if(d.kind==="entry-point")return null;if(d.path.match(/@donotdev\/functions\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/functions/","");return{path:u.normalizePath(`${r.root}/packages/functions/src/${g}/index.ts`)}}if(d.path==="@donotdev/utils")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:y.resolve("@donotdev/utils/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let g=d.path.replace("@donotdev/utils/","");return{path:u.normalizePath(`${r.root}/packages/core/utils/src/${g}/index.ts`)}}if(d.path==="@donotdev/core")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/server.ts`)}:y.resolve("@donotdev/core/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/core\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return{path:d.path,external:!0};if(d.path.match(/@donotdev\/core\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(d.path.startsWith("@donotdev/")||d.path==="valibot"||d.path.startsWith("valibot/"))return null;if(O.length>0){let g=d.path.split("/")[0];if(O.includes(g))return null}return d.path.startsWith(".")||d.path.startsWith("/")?null:{path:d.path,external:!0}})}};if(m.external=[...A,"firebase-admin","firebase-functions"],m.plugins=[L,...m.plugins||[]],m.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...m.define||{}},l&&r.type==="dndev"){let y=r.root,d=u.normalizePath(`${y}/functions/lib`);m.alias={...m.alias,"@donotdev/functions":d}}return s==="framework"&&(m.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),m}import{readFileSync as C,writeFileSync as B,existsSync as N}from"fs";import"path";var U=["create","get","list","listCard","update","delete"];function Q(a,e=0){let t=" ".repeat(e),o="";for(let[n,s]of Object.entries(a))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))Object.keys(s).length===0?o+=`${t}${n}: {}
2
- `:o+=`${t}${n}:
3
- ${Q(s,e+1)}`;else if(Array.isArray(s))if(s.length===0)o+=`${t}${n}: []
4
- `;else{o+=`${t}${n}:
5
- `;for(let r of s)if(typeof r=="object"&&r!==null){let c=Object.entries(r),[l,p]=c[0];o+=`${t} - ${l}: ${p}
6
- `;for(let i=1;i<c.length;i++){let[u,f]=c[i];o+=`${t} ${u}: ${f}
7
- `}}else o+=`${t} - ${r}
8
- `}else o+=`${t}${n}: ${s}
9
- `;return o}var de=["X_GOOGLE_","FIREBASE_","EXT_","GCLOUD_"],he=["FIREBASE_REGION","FIREBASE_PROJECT_ID","FIREBASE_AUTH_DOMAIN","ENABLE_RATE_LIMITING","DISABLE_RATE_LIMITING","ENABLE_METRICS","DISABLE_METRICS","ENFORCE_APP_CHECK"];function ee(a){if(!N(a))return[];let e=C(a,"utf-8"),t=[],o=e.matchAll(/export\s*\{([^}]+)\}/g);for(let s of o)if(s[1]){let r=s[1].split(",").map(c=>{let l=c.trim().split(/\s+as\s+/);return(l[1]||l[0]||"").trim()}).filter(Boolean);t.push(...r)}let n=e.matchAll(/export\s+const\s+(\w+)/g);for(let s of n)s[1]&&t.push(s[1]);return[...new Set(t)]}function _(a=".env"){if(!N(a))return[];let e=C(a,"utf-8"),t=[];for(let o of e.split(/\r?\n/)){let n=o.trim();if(!n||n.startsWith("#"))continue;let s=n.indexOf("=");if(s<=0)continue;let r=n.substring(0,s).trim();he.includes(r)||de.some(c=>r.startsWith(c))||t.push(r)}return t}function te(a){return U.some(e=>a.startsWith(`${e}_`))}function re(a,e={}){let t=a.defaults||{},o=t.labels||{},n={},s=e.envPath?_(e.envPath):_(),r=s.length>0?s.map(u=>({key:u})):void 0,c=e.entryFile?ee(e.entryFile):[],l=a.functions||{},p=new Set(Object.keys(l));for(let u of c)!te(u)&&!p.has(u)&&p.add(u);for(let u of p){let f=l[u]||{},m={...o,...f.labels};f.category&&(m.category=f.category),n[u]={region:f.region||t.region||["europe-west1"],platform:f.platform||t.platform||"gcfv2",entryPoint:f.entryPoint||u,labels:m},f.trigger==="http"?n[u].httpsTrigger={}:n[u].callableTrigger={},f.secrets?.length?n[u].secretEnvironmentVariables=f.secrets.map(A=>({key:A})):r&&(n[u].secretEnvironmentVariables=r)}if(a.crud?.entities)for(let u of a.crud.entities)for(let f of U){let m=`${f}_${u}`;n[m]={region:t.region||["europe-west1"],platform:t.platform||"gcfv2",callableTrigger:{},entryPoint:m,labels:{...o,category:"crud"}},r&&(n[m].secretEnvironmentVariables=r)}return`# Firebase Functions Configuration
1
+ import F from"node:fs";import k from"node:path";import{fileURLToPath as oe}from"node:url";var ne=oe(import.meta.url),be=k.dirname(ne);function $(){let a=process.cwd(),e=10;for(let t=0;t<e;t++){let s=k.join(a,"package.json");if(F.existsSync(s))try{let o=JSON.parse(F.readFileSync(s,"utf8")),r=o.workspaces&&Array.isArray(o.workspaces);if(r&&o.workspaces.some(i=>i==="packages/**"||i.startsWith("packages/"))&&(F.existsSync(k.join(a,"packages","core"))||F.existsSync(k.join(a,"packages","functions"))))return{type:"dndev",root:a};if(r&&o.workspaces.some(i=>i.includes("dndev/packages"))){let u=o.workspaces.find(m=>m.includes("dndev/packages")).replace(/\/packages.*$/,""),f=k.resolve(a,u);if(F.existsSync(k.join(f,"packages","core")))return{type:"dndev",root:f}}}catch{}let n=k.dirname(a);if(n===a)break;a=n}return{type:"npm",root:process.cwd()}}function ie(a){return a.type==="dndev"?a.root:null}function H(a){let e={};if(a.type==="dndev"){let t=ie(a);t&&(e["@donotdev/types"]=k.join(t,"packages","core","types","src"),e["@donotdev/functions"]=k.join(t,"packages","functions","src"),e["@donotdev/utils"]=k.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=k.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=k.join(t,"packages","core"))}return e}import*as h from"node:fs";import"node:fs";import{createRequire as ce}from"node:module";import{resolve as j,join as b,dirname as w,relative as K,normalize as le,sep as q,extname as ue}from"node:path";import{fileURLToPath as pe}from"node:url";import fe from"fast-glob";var I={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},E={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json","../../entities/locales/*_*.json"],additional:[],framework:{eager:[`${I.SOURCE_EAGER}/*_*.json`],lazy:[`${I.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]};var Y={base:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...E.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:E.globalIgnore}};function V(a,e=null){let t=E[a];if(!t)throw new Error(`Unknown pattern type: ${a}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function J(a){return Y[a]||Y.base}var S={getGlobOptionsFor:J||void 0,SCAN_PATTERNS:E||void 0,getPatternsFor:V||void 0,I18N_PATHS:I||void 0},v={error:(a,e)=>{},warn:(a,e)=>{},info:a=>{}};function X(a,e){return a().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var Z={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},D=class a{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return a._instance||(a._instance=new a(e)),a._instance}static _reset(){a._instance=null}constructor(e={}){if(a._instance)return a._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=process.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${process.cwd()}`)}this._appRoot=null,a._instance=this}normalizePath(e){if(!e)return"";try{return le(e).split(q).join("/")}catch{return String(e).split(q).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=K(t,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(w(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=ce(b(s,"package.json")).resolve(e);return this.normalizePath(o)}catch{return null}}resolveFrameworkPackage(e,t=null){let s=this.resolvePackage(`${e}/package.json`,t);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let r=e.replace("@donotdev/",""),c=this.resolveRepoPath(`packages/${r}`);if(this.pathExists(c))return c;if(["auth","billing","crud","oauth"].includes(r)){let l=this.resolveRepoPath(`packages/features/${r}`);if(this.pathExists(l))return l}if(r==="firebase"){let l=this.resolveRepoPath(`packages/providers/${r}`);if(this.pathExists(l))return l}}let n=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(n))return n;let o=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(o)?o:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),s=j(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),n=j(t,s);return this.normalizePath(n)}resolvePath(e,t){let s=this.normalizePath(t),n=this.normalizePath(e),o=j(s,n);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=h.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:ue(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:n="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await h.promises.readFile(e);let r=await h.promises.readFile(e,n),c=this.stripBom(r);return o==="json"?JSON.parse(c):c}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}readSync(e,t={}){let{format:s="auto",encoding:n="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return h.readFileSync(e);let r=h.readFileSync(e,n),c=this.stripBom(r);return o==="json"?JSON.parse(c):c}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}async write(e,t,s={}){let{format:n="auto",overwrite:o=!1,dryRun:r=!1,verbose:c=!1}=s,l=this.normalizePath(e),p=this.normalizePath(w(l)),i=this.pathExists(l);if(i&&!o)return c&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{await h.promises.mkdir(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return await X(async()=>(Buffer.isBuffer(f)?await h.promises.writeFile(l,f):await h.promises.writeFile(l,f,"utf8"),c&&v.info(`${i?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:n="auto",overwrite:o=!1,dryRun:r=!1,verbose:c=!1}=s,l=this.normalizePath(e),p=this.normalizePath(w(l)),i=this.pathExists(l);if(i&&!o)return c&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{h.mkdirSync(p,{recursive:!0})}catch(m){if(m?.code!=="EEXIST")throw m}let u=this._detectFormat(e,n),f;Buffer.isBuffer(t)?f=t:u==="json"&&typeof t=="object"?f=JSON.stringify(t,null,2):f=String(t);try{return Buffer.isBuffer(f)?h.writeFileSync(l,f):h.writeFileSync(l,f,"utf8"),c&&v.info(`${i?"Updated":"Created"} file: ${l}`),!0}catch(m){throw new Error(`Failed to write file: ${l}: ${m instanceof Error?m.message:String(m)}`)}}async copy(e,t,s={}){let{overwrite:n=!1,dryRun:o=!1,verbose:r=!1}=s,c=this.normalizePath(t),l=this.pathExists(c);if(l&&!n)return r&&v.info(`Skipping existing file: ${c}`),!1;if(o)return v.info(`[DRY RUN] Would copy file: ${c}`),!0;let p=this.normalizePath(w(c));try{await h.promises.mkdir(p,{recursive:!0})}catch(i){if(i?.code!=="EEXIST")throw i}try{return await X(async()=>(await h.promises.copyFile(e,c),r&&v.info(`${l?"Updated":"Created"} file: ${c}`),!0),`Failed to copy file from ${e} to ${c}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:n=!1,dryRun:o=!1,verbose:r=!1}=s,c=this.normalizePath(t),l=this.pathExists(c);if(l&&!n)return r&&v.info(`Skipping existing file: ${c}`),!1;if(o)return v.info(`[DRY RUN] Would copy file: ${c}`),!0;let p=this.normalizePath(w(c));try{h.mkdirSync(p,{recursive:!0})}catch(i){if(i?.code!=="EEXIST")throw i}try{return h.copyFileSync(e,c),r&&v.info(`${l?"Updated":"Created"} file: ${c}`),!0}catch{return!1}}pathExists(e,t=!1){try{return h.existsSync(e)}catch(s){return t||v.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return h.existsSync(t)||h.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return h.readdirSync(e,t)}catch(s){return this.options.debug&&v.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return h.statSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return h.realpathSync(e)}watch(e,t,s){return h.watch(e,t,s)}lstatSync(e){try{return h.lstatSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await h.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{h.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await h.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){h.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return h.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||process.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=b(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(j(e)),s=this.getAppRoot(),n=K(s,t),o=this.normalizePath(n);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let n=this.normalizePath(b(e,t)),o=this.getAppRoot(),r=this.normalizePath(o),c=n.startsWith(r)?n.slice(r.length+1):n,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:S.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([c],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=S.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),n=this.resolveFrameworkPackage("@donotdev/core");if(!n)return null;let o=this.normalizePath(b(n,t.PUBLISHED_ROOT,s)),r=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),o}async _globWithNormalization(e,t){return(await fe(e,t)).map(n=>{let o=typeof n=="string"?n:n.path;return this.normalizePath(o)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let i of s)if(typeof i!="string"||i.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let n=this.getAppRoot(),o=S.getGlobOptionsFor?S.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(n),c=e.framework.map(i=>{let u=this.normalizePath(i);return u.startsWith(r)?u.slice(r.length+1):u}),l=e.consumer.map(i=>{let u=this.normalizePath(i);return u.startsWith(r)?u.slice(r.length+1):u}),p={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:n};try{let i=c.length>0?await this._globWithNormalization(c,p):[],u=await this._globWithNormalization(l,p);return{frameworkFiles:i,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!S.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),s=this.getRepoRoot();if(e==="i18n"&&(!t||t===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let n=S.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=n,p={eager:l.eager.map(i=>i.startsWith("!")?"!"+this.resolveAppPath(i.slice(1)):this.resolveAppPath(i)),lazy:l.lazy.map(i=>i.startsWith("!")?"!"+this.resolveAppPath(i.slice(1)):this.resolveAppPath(i)),framework:{eager:o?(l.framework?.eager||[]).map(i=>this.resolveRepoPath(i)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(i=>this._resolveFrameworkI18nPattern(i))).then(i=>i.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(i=>this.resolveRepoPath(i)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(i=>this._resolveFrameworkI18nPattern(i))).then(i=>i.filter(Boolean))},all:[]};return p.all=[...p.eager,...p.lazy,...p.framework.eager,...p.framework.lazy],p}let r=n,c={framework:o?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return c.all=[...c.consumer,...c.framework],c}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let s=w(pe(import.meta.url));return this.normalizePath(b(s,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),s=0,n=this.options.maxLevels;for(;s<n;){let o=this.normalizePath(b(t,Z.TOOLING)),r=this.normalizePath(b(t,Z.CORE));if(this.pathExists(o)&&this.pathExists(r))return t;let c=b(t,"apps");if(this.pathExists(c)&&this.statSync(c)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(b(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(w(t))===t)return t;let p=this.normalizePath(w(t));if(p===t)break;t=p,s++}return this.normalizePath(e)}};function T(a={}){let{entry:e="src/index.ts",outDir:t="lib",minify:s=!1,sourcemap:n=!0,platform:o="firebase",workspace:r,bundleWorkspaceDeps:c=!1,importFramework:l=!1,external:p=!1,...i}=a,u=D.getInstance(),f=H(r),m={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:s,sourcemap:n,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...i};c&&Object.keys(f).length>0&&(m.alias=Object.fromEntries(Object.entries(f).map(([y,d])=>[y,u.normalizePath(d)]))),m.mainFields=["module","main"],m.conditions=["import","module","node"];let A=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],O=[];if(c)try{let y=r?.root||process.cwd(),d=process.cwd(),g=10;for(let P=0;P<g;P++){let W=u.normalizePath(`${d}/package.json`);if(u.pathExists(W)){let x=u.readSync(W,{format:"json"});if(x&&Array.isArray(x.workspaces)){y=u.normalizePath(d);for(let R of x.workspaces)R==="apps/*"||R==="functions"||!R.includes("*")&&!R.includes("/")&&O.push(R);break}}let z=u.getDirname(d);if(z===d)break;d=z}}catch{}let L={name:"external-node-modules",setup(y){y.onResolve({filter:/^firebase($|\/)/},d=>{if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return null;let g;if(r?.type==="dndev"&&r.root)g=u.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let P=import.meta.url,z=new URL(P).pathname.replace(/^\/([A-Z]:)/i,"$1"),x=u.getDirname(z);g=u.normalizePath(`${x}/firebase-stub.js`)}return{path:g}}),y.onResolve({filter:/.*/},d=>{if(d.kind==="entry-point")return null;if(d.path.match(/@donotdev\/functions\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/functions/","");return{path:u.normalizePath(`${r.root}/packages/functions/src/${g}/index.ts`)}}if(d.path==="@donotdev/utils")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:y.resolve("@donotdev/utils/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let g=d.path.replace("@donotdev/utils/","");return{path:u.normalizePath(`${r.root}/packages/core/utils/src/${g}/index.ts`)}}if(d.path==="@donotdev/core")return r?.type==="dndev"?{path:u.normalizePath(`${r.root}/packages/core/server.ts`)}:y.resolve("@donotdev/core/server",{kind:d.kind,resolveDir:d.resolveDir});if(d.path.match(/@donotdev\/core\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(d.path==="firebase-admin"||d.path.startsWith("firebase-admin/")||d.path==="firebase-functions"||d.path.startsWith("firebase-functions/"))return{path:d.path,external:!0};if(d.path.match(/@donotdev\/core\/.+/)&&c&&r?.type==="dndev"){let g=d.path.replace("@donotdev/core/","");return{path:u.normalizePath(`${r.root}/packages/core/${g}.ts`)}}if(d.path.startsWith("@donotdev/")||d.path==="valibot"||d.path.startsWith("valibot/"))return null;if(O.length>0){let g=d.path.split("/")[0];if(O.includes(g))return null}return d.path.startsWith(".")||d.path.startsWith("/")?null:{path:d.path,external:!0}})}};if(m.external=[...A,"firebase-admin","firebase-functions"],m.plugins=[L,...m.plugins||[]],m.define={"process.env.NODE_ENV":JSON.stringify(process.env.NODE_ENV||"production"),...m.define||{}},l&&r.type==="dndev"){let y=r.root,d=u.normalizePath(`${y}/functions/lib`);m.alias={...m.alias,"@donotdev/functions":d}}return o==="framework"&&(m.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),m}import{readFileSync as C,writeFileSync as B,existsSync as N}from"fs";import"path";var U=["create","get","list","listCard","update","delete"];function Q(a,e=0){let t=" ".repeat(e),s="";for(let[n,o]of Object.entries(a))if(o!=null)if(typeof o=="object"&&!Array.isArray(o))Object.keys(o).length===0?s+=`${t}${n}: {}
2
+ `:s+=`${t}${n}:
3
+ ${Q(o,e+1)}`;else if(Array.isArray(o))if(o.length===0)s+=`${t}${n}: []
4
+ `;else{s+=`${t}${n}:
5
+ `;for(let r of o)if(typeof r=="object"&&r!==null){let c=Object.entries(r),[l,p]=c[0];s+=`${t} - ${l}: ${p}
6
+ `;for(let i=1;i<c.length;i++){let[u,f]=c[i];s+=`${t} ${u}: ${f}
7
+ `}}else s+=`${t} - ${r}
8
+ `}else s+=`${t}${n}: ${o}
9
+ `;return s}var de=["X_GOOGLE_","FIREBASE_","EXT_","GCLOUD_"],he=["FIREBASE_REGION","FIREBASE_PROJECT_ID","FIREBASE_AUTH_DOMAIN","ENABLE_RATE_LIMITING","DISABLE_RATE_LIMITING","ENABLE_METRICS","DISABLE_METRICS","ENFORCE_APP_CHECK"];function ee(a){if(!N(a))return[];let e=C(a,"utf-8"),t=[],s=e.matchAll(/export\s*\{([^}]+)\}/g);for(let o of s)if(o[1]){let r=o[1].split(",").map(c=>{let l=c.trim().split(/\s+as\s+/);return(l[1]||l[0]||"").trim()}).filter(Boolean);t.push(...r)}let n=e.matchAll(/export\s+const\s+(\w+)/g);for(let o of n)o[1]&&t.push(o[1]);return[...new Set(t)]}function _(a=".env"){if(!N(a))return[];let e=C(a,"utf-8"),t=[];for(let s of e.split(/\r?\n/)){let n=s.trim();if(!n||n.startsWith("#"))continue;let o=n.indexOf("=");if(o<=0)continue;let r=n.substring(0,o).trim();he.includes(r)||de.some(c=>r.startsWith(c))||t.push(r)}return t}function te(a){return U.some(e=>a.startsWith(`${e}_`))}function re(a,e={}){let t=a.defaults||{},s=t.labels||{},n={},o=e.envPath?_(e.envPath):_(),r=o.length>0?o.map(u=>({key:u})):void 0,c=e.entryFile?ee(e.entryFile):[],l=a.functions||{},p=new Set(Object.keys(l));for(let u of c)!te(u)&&!p.has(u)&&p.add(u);for(let u of p){let f=l[u]||{},m={...s,...f.labels};f.category&&(m.category=f.category),n[u]={region:f.region||t.region||["europe-west1"],platform:f.platform||t.platform||"gcfv2",entryPoint:f.entryPoint||u,labels:m},f.trigger==="http"?n[u].httpsTrigger={}:n[u].callableTrigger={},f.secrets?.length?n[u].secretEnvironmentVariables=f.secrets.map(A=>({key:A})):r&&(n[u].secretEnvironmentVariables=r)}if(a.crud?.entities)for(let u of a.crud.entities)for(let f of U){let m=`${f}_${u}`;n[m]={region:t.region||["europe-west1"],platform:t.platform||"gcfv2",callableTrigger:{},entryPoint:m,labels:{...s,category:"crud"}},r&&(n[m].secretEnvironmentVariables=r)}return`# Firebase Functions Configuration
10
10
  # Generated by @donotdev/core/functions - DO NOT EDIT MANUALLY
11
11
  # Generated at: ${new Date().toISOString()}
12
12
 
13
- `+Q({endpoints:n,specVersion:"v1alpha1",requiredAPIs:[]})}function M(a,e={}){let t=Object.keys(a.functions||{}),o=[];if(a.crud?.entities)for(let l of a.crud.entities)for(let p of U)o.push(`${p}_${l}`);let s=(e.entryFile?ee(e.entryFile):[]).filter(l=>!te(l)&&!t.includes(l)),r=[...t,...s],c=e.envPath?_(e.envPath):_();return{yaml:re(a,e),functions:[...r,...o],staticFunctions:r,crudFunctions:o,autoDetected:s,autoSecrets:c}}function G(a){let e=new Set;for(let p of Object.values(a.functions||{}))if(p.secrets)for(let i of p.secrets)e.add(i);let t=_();for(let p of t)e.add(p);if(e.size===0||!N(".env"))return{stripped:[],kept:0};let n=C(".env","utf-8").split(/\r?\n/),s=[],r=[];for(let p of n){let i=p.trim();if(!i||i.startsWith("#")){s.push(p);continue}let u=i.indexOf("="),f=u>0?i.substring(0,u).trim():"";e.has(f)?r.push(p):s.push(p)}if(r.length===0)return{stripped:[],kept:s.length};B(".env",s.join(`
13
+ `+Q({endpoints:n,specVersion:"v1alpha1",requiredAPIs:[]})}function M(a,e={}){let t=Object.keys(a.functions||{}),s=[];if(a.crud?.entities)for(let l of a.crud.entities)for(let p of U)s.push(`${p}_${l}`);let o=(e.entryFile?ee(e.entryFile):[]).filter(l=>!te(l)&&!t.includes(l)),r=[...t,...o],c=e.envPath?_(e.envPath):_();return{yaml:re(a,e),functions:[...r,...s],staticFunctions:r,crudFunctions:s,autoDetected:o,autoSecrets:c}}function G(a){let e=new Set;for(let p of Object.values(a.functions||{}))if(p.secrets)for(let i of p.secrets)e.add(i);let t=_();for(let p of t)e.add(p);if(e.size===0||!N(".env"))return{stripped:[],kept:0};let n=C(".env","utf-8").split(/\r?\n/),o=[],r=[];for(let p of n){let i=p.trim();if(!i||i.startsWith("#")){o.push(p);continue}let u=i.indexOf("="),f=u>0?i.substring(0,u).trim():"";e.has(f)?r.push(p):o.push(p)}if(r.length===0)return{stripped:[],kept:o.length};B(".env",o.join(`
14
14
  `));let c=`# Secrets managed by sync-secrets (auto-filtered by build)
15
15
  `;if(N(".env.local")){let p=C(".env.local","utf-8"),i=new Set(p.split(/\r?\n/).filter(f=>f.trim()&&!f.trim().startsWith("#")).map(f=>f.split("=")[0].trim())),u=r.filter(f=>!i.has(f.split("=")[0].trim()));u.length>0&&B(".env.local",p.trimEnd()+`
16
16
  `+c+u.join(`
17
17
  `)+`
18
18
  `)}else B(".env.local",c+r.join(`
19
19
  `)+`
20
- `);return{stripped:r.map(p=>p.split("=")[0].trim()),kept:s.length}}import{writeFileSync as me}from"fs";function ge(a={}){let e=$();return T({...a,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0,workspace:e})}async function ve(a,e={}){let{entry:t="src/index.ts",outDir:o="lib",minify:n=process.env.NODE_ENV==="production",sourcemap:s=!0,analyze:r=!1,entryFile:c="src/index.ts",envPath:l=".env",...p}=e;try{let{build:i}=await import("esbuild"),u=ge({entry:t,outDir:o,minify:n,sourcemap:s,...p}),f=await i(u);f.errors.length>0&&process.exit(1),f.warnings.length>0;let{yaml:m,staticFunctions:A,crudFunctions:O,autoDetected:L,autoSecrets:y}=M(a,{entryFile:c,envPath:l});me("functions.yaml",m),L.length>0,y.length>0;let{stripped:d}=G(a);if(d.length>0,r&&f.metafile){let{analyzeMetafile:g}=await import("esbuild"),P=await g(f.metafile)}}catch{process.exit(1)}}function se(a={}){let{entry:e="src/index.ts",outDir:t="lib",minify:o=!1,sourcemap:n=!0,platform:s="firebase",...r}=a,c=$();return T({entry:e,outDir:t,minify:o,sourcemap:n,platform:s,workspace:c,...r})}function He(a={}){return se({...a,platform:"framework",bundleWorkspaceDeps:!0})}function Ye(a={}){return se({...a,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{ve as buildFunctions,Ye as createAppFunctionsConfig,se as createFunctionsEsbuildConfig,He as createRootFunctionsConfig,G as filterEnvSecrets,re as generateFunctionsYaml,M as generateFunctionsYamlWithInfo};
20
+ `);return{stripped:r.map(p=>p.split("=")[0].trim()),kept:o.length}}import{writeFileSync as me}from"fs";function ge(a={}){let e=$();return T({...a,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0,workspace:e})}async function ve(a,e={}){let{entry:t="src/index.ts",outDir:s="lib",minify:n=process.env.NODE_ENV==="production",sourcemap:o=!0,analyze:r=!1,entryFile:c="src/index.ts",envPath:l=".env",...p}=e;try{let{build:i}=await import("esbuild"),u=ge({entry:t,outDir:s,minify:n,sourcemap:o,...p}),f=await i(u);f.errors.length>0&&process.exit(1),f.warnings.length>0;let{yaml:m,staticFunctions:A,crudFunctions:O,autoDetected:L,autoSecrets:y}=M(a,{entryFile:c,envPath:l});me("functions.yaml",m),L.length>0,y.length>0;let{stripped:d}=G(a);if(d.length>0,r&&f.metafile){let{analyzeMetafile:g}=await import("esbuild"),P=await g(f.metafile)}}catch{process.exit(1)}}function se(a={}){let{entry:e="src/index.ts",outDir:t="lib",minify:s=!1,sourcemap:n=!0,platform:o="firebase",...r}=a,c=$();return T({entry:e,outDir:t,minify:s,sourcemap:n,platform:o,workspace:c,...r})}function He(a={}){return se({...a,platform:"framework",bundleWorkspaceDeps:!0})}function Ye(a={}){return se({...a,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{ve as buildFunctions,Ye as createAppFunctionsConfig,se as createFunctionsEsbuildConfig,He as createRootFunctionsConfig,G as filterEnvSecrets,re as generateFunctionsYaml,M as generateFunctionsYamlWithInfo};
package/index.d.ts CHANGED
@@ -16590,8 +16590,8 @@ declare function clearPartnerCache(): void;
16590
16590
  declare function getPartnerCacheStatus(): {
16591
16591
  authPartnersCached: boolean;
16592
16592
  oauthPartnersCached: boolean;
16593
- authPartners: ("apple" | "discord" | "emailLink" | "facebook" | "github" | "google" | "linkedin" | "microsoft" | "password" | "reddit" | "spotify" | "twitch" | "twitter" | "yahoo")[] | null;
16594
- oauthPartners: ("discord" | "github" | "google" | "linkedin" | "reddit" | "spotify" | "twitch" | "twitter" | "notion" | "slack" | "medium" | "mastodon" | "youtube")[] | null;
16593
+ authPartners: ("password" | "apple" | "discord" | "emailLink" | "facebook" | "github" | "google" | "linkedin" | "microsoft" | "reddit" | "spotify" | "twitch" | "twitter" | "yahoo")[] | null;
16594
+ oauthPartners: ("medium" | "discord" | "github" | "google" | "linkedin" | "reddit" | "spotify" | "twitch" | "twitter" | "notion" | "slack" | "mastodon" | "youtube")[] | null;
16595
16595
  };
16596
16596
  /**
16597
16597
  * Get AuthPartnerId from Firebase provider ID
@@ -24608,7 +24608,7 @@ interface UseBreathingTimerProps {
24608
24608
  * @author AMBROISE PARK Consulting
24609
24609
  */
24610
24610
  declare function useBreathingTimer({ duration, onComplete, }: UseBreathingTimerProps): {
24611
- status: "active" | "idle" | "paused" | "complete";
24611
+ status: "paused" | "idle" | "active" | "complete";
24612
24612
  timeRemaining: number;
24613
24613
  start: () => void;
24614
24614
  togglePause: () => void;