@donotdev/core 0.0.35 → 0.0.36
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/index.d.ts +7 -15
- package/index.js +32 -32
- package/next/index.js +36 -35
- package/package.json +2 -2
- package/server.d.ts +3 -10
- package/server.js +1 -1
- package/vite/index.js +1 -1
package/vite/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Kt=Object.defineProperty;var je=(n,e)=>()=>(n&&(e=n(n=0)),e);var Zt=(n,e)=>{for(var t in e)Kt(n,t,{get:e[t],enumerable:!0})};function nt(n,e=null){let t=Q[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function ke(n){return rt[n]||rt.base}var Ge,C,B,z,We,we,De,Q,he,ot,Be,Ve,xe,He,rt,j=je(()=>{"use strict";Ge={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},C={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env"},B={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},z={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configServer:"src/config/dndev-config-server.js"},vite:{routeInspection:"src/routes.generated.log",themeInspection:"src/themes.generated.log",i18nInspection:"src/i18n.generated.log",assetInspection:"src/assets.generated.log",envInspection:"src/env.generated.log"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},We={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},we={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},De={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"},Q={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:[`${De.SOURCE_EAGER}/*_*.json`],lazy:[`${De.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/**"]},he={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async","@donotdev/core","@donotdev/components","@donotdev/ui","@donotdev/templates","@donotdev/firebase"],optionalFeatures:["@donotdev/components","@donotdev/auth","@donotdev/billing","@donotdev/crud","@donotdev/oauth","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder"],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},ot=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],Be=["@donotdev/core/functions","@donotdev/core/server"],Ve={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},xe={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin","Press Start 2P":"press-start-2p-latin",Roboto:"roboto-latin"},He=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],rt={base:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...Q.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...Q.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore}}});import*as P from"node:fs";import"node:fs";import{createRequire as os}from"node:module";import{resolve as Ae,join as ce,dirname as pe,relative as at,normalize as ns,sep as it,extname as as}from"node:path";import{fileURLToPath as is}from"node:url";import ls from"fast-glob";function lt(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var ve,U,ct,O,q=je(()=>{"use strict";j();ve={getGlobOptionsFor:ke||void 0,SCAN_PATTERNS:Q||void 0,getPatternsFor:nt||void 0,I18N_PATHS:De||void 0},U={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};ct={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"},O=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._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,n._instance=this}normalizePath(e){if(!e)return"";try{return ns(e).split(it).join("/")}catch{return String(e).split(it).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=at(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(pe(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=os(ce(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 a=e.replace("@donotdev/",""),i=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(i))return i;if(["auth","billing","crud","oauth"].includes(a)){let l=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(l))return l}if(a==="firebase"){let l=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(l))return l}}let r=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(r))return r;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=Ae(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=Ae(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=Ae(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=P.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:as(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await P.promises.readFile(e);let a=await P.promises.readFile(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&U.warn(`Failed to read file: ${e}`,a),null}}readSync(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return P.readFileSync(e);let a=P.readFileSync(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&U.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),u=this.normalizePath(pe(l)),c=this.pathExists(l);if(c&&!o)return i&&U.info(`Skipping existing file: ${l}`),!1;if(a)return U.info(`[DRY RUN] Would write file: ${l}`),!0;try{await P.promises.mkdir(u,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await lt(async()=>(Buffer.isBuffer(g)?await P.promises.writeFile(l,g):await P.promises.writeFile(l,g,"utf8"),i&&U.info(`${c?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),u=this.normalizePath(pe(l)),c=this.pathExists(l);if(c&&!o)return i&&U.info(`Skipping existing file: ${l}`),!1;if(a)return U.info(`[DRY RUN] Would write file: ${l}`),!0;try{P.mkdirSync(u,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?P.writeFileSync(l,g):P.writeFileSync(l,g,"utf8"),i&&U.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(d){throw new Error(`Failed to write file: ${l}: ${d instanceof Error?d.message:String(d)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&U.info(`Skipping existing file: ${i}`),!1;if(o)return U.info(`[DRY RUN] Would copy file: ${i}`),!0;let u=this.normalizePath(pe(i));try{await P.promises.mkdir(u,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await lt(async()=>(await P.promises.copyFile(e,i),a&&U.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&U.info(`Skipping existing file: ${i}`),!1;if(o)return U.info(`[DRY RUN] Would copy file: ${i}`),!0;let u=this.normalizePath(pe(i));try{P.mkdirSync(u,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return P.copyFileSync(e,i),a&&U.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return P.existsSync(e)}catch(s){return t||U.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 P.existsSync(t)||P.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return P.readdirSync(e,t)}catch(s){return this.options.debug&&U.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return P.statSync(e)}catch(t){return this.options.debug&&U.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return P.realpathSync(e)}watch(e,t,s){return P.watch(e,t,s)}lstatSync(e){try{return P.lstatSync(e)}catch(t){return this.options.debug&&U.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await P.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{P.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await P.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){P.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return P.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=ce(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(Ae(e)),s=this.getAppRoot(),r=at(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(ce(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),i=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:ve.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=ve.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),r=this.resolveFrameworkPackage("@donotdev/core");if(!r)return null;let o=this.normalizePath(ce(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await ls(e,t)).map(r=>{let o=typeof r=="string"?r:r.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 c of s)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let r=this.getAppRoot(),o=ve.getGlobOptionsFor?ve.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),i=e.framework.map(c=>{let p=this.normalizePath(c);return p.startsWith(a)?p.slice(a.length+1):p}),l=e.consumer.map(c=>{let p=this.normalizePath(c);return p.startsWith(a)?p.slice(a.length+1):p}),u={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let c=i.length>0?await this._globWithNormalization(i,u):[],p=await this._globWithNormalization(l,u);return{frameworkFiles:c,consumerFiles:p}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!ve.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 r=ve.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,u={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:o?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return u.all=[...u.eager,...u.lazy,...u.framework.eager,...u.framework.lazy],u}let a=r,i={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let s=pe(is(import.meta.url));return this.normalizePath(ce(s,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(ce(t,ct.TOOLING)),a=this.normalizePath(ce(t,ct.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let i=ce(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(ce(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(pe(t))===t)return t;let u=this.normalizePath(pe(t));if(u===t)break;t=u,s++}return this.normalizePath(e)}}});var Ht={};Zt(Ht,{createDndevPlugin:()=>sr});import{execSync as Me,spawn as zs}from"node:child_process";function J(){return O.getInstance()}function Ut(){return J().getRepoRoot()}function Gt(){return J().resolveRepoPath(".dndev")}function y(n,e,t=200){n.writeHead(t,{"Content-Type":"application/json"}),n.end(JSON.stringify(e))}function Pe(n,e=js){return new Promise((t,s)=>{let r="",o=0;n.on("data",a=>{if(o+=a.length,o>e){n.destroy(),s(new Error("Request body too large"));return}r+=a.toString()}),n.on("end",()=>t(r)),n.on("error",s)})}function Us(n){let e=n.lastIndexOf(".");return e===-1?"":n.slice(e).toLowerCase()}function Gs(){let n=J(),e=[],t=process.env.HOME||process.env.USERPROFILE||"";try{let r=process.platform==="win32"?"where node":"which node",o=Me(r,{encoding:"utf8"}).trim().split(`
|
|
1
|
+
var Kt=Object.defineProperty;var je=(n,e)=>()=>(n&&(e=n(n=0)),e);var Zt=(n,e)=>{for(var t in e)Kt(n,t,{get:e[t],enumerable:!0})};function nt(n,e=null){let t=Q[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function ke(n){return rt[n]||rt.base}var Ge,C,B,z,We,we,De,Q,he,ot,Be,Ve,xe,He,rt,j=je(()=>{"use strict";Ge={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"},C={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env"},B={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},z={next:{middleware:"middleware.ts",routeManifest:"public/route-manifest.json",assetManifest:"public/asset-manifest.json",utilities:"src/styles/utilities.generated.css",appPages:"src/app",appLayout:"src/app/layout.tsx",configRoute:"src/config/dndev-config-route.js",configTheme:"src/config/dndev-config-theme.js",configI18n:"src/config/dndev-config-i18n.js",configPwa:"src/config/dndev-config-pwa.js",configAsset:"src/config/dndev-config-asset.js",configSeo:"src/config/dndev-config-seo.js",configServer:"src/config/dndev-config-server.js"},vite:{routeInspection:"src/routes.generated.log",themeInspection:"src/themes.generated.log",i18nInspection:"src/i18n.generated.log",assetInspection:"src/assets.generated.log",envInspection:"src/env.generated.log"},manifests:{route:"route-manifest.json",theme:"theme-manifest.json",i18n:"i18n-manifest.json",asset:"asset-manifest.json",feature:"feature-manifest.json",env:"env-manifest.json"}},We={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},we={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},De={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"},Q={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:[`${De.SOURCE_EAGER}/*_*.json`],lazy:[`${De.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/**"]},he={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async","@donotdev/core","@donotdev/components","@donotdev/ui","@donotdev/templates","@donotdev/firebase"],optionalFeatures:[],coreBundled:["@donotdev/types","@donotdev/utils","@donotdev/stores","@donotdev/schemas","@donotdev/hooks","@donotdev/i18n","@donotdev/config"],componentsBundled:["class-variance-authority","clsx","lucide-react","react-day-picker"],radixUIPattern:"@radix-ui/",buildTools:["esbuild","@esbuild/win32-x64","@esbuild/darwin-x64","@esbuild/linux-x64","@esbuild/darwin-arm64","@esbuild/linux-arm64","vite","rollup","rollup-plugin-visualizer","@vitejs/plugin-react","vite-tsconfig-paths","vite-plugin-pwa","vite-plugin-compression2","vite-plugin-node-polyfills","fsevents","postcss","postcss-import","postcss-nesting","autoprefixer"],buildTimePackages:[],largeOptional:["@sentry/react","framer-motion","stripe","@tanstack/react-query","shiki","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-placeholder","sharp","semver","file-type"]},ot=["firebase-admin","gcp-metadata","google-logging-utils","payload","undici","@fastify/busboy","image-size","@donotdev/tooling","fs","path","crypto","net","tls","http","https","child_process","os","util","stream","buffer","events","querystring","url","zlib","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","cluster","dgram","dns","http2","inspector","module","perf_hooks","process","readline","repl","trace_events","v8","wasi"],Be=["@donotdev/core/functions","@donotdev/core/server"],Ve={selectors:{class:/\.([a-zA-Z0-9-]+)/g,variable:/--[a-zA-Z0-9-]+/g,keyframe:/@keyframes\s+([a-zA-Z0-9-]+)/g},themes:{themeClass:/(?::root\.|\.)([a-z][a-z0-9-]+)\s*\{([\s\S]*?)\}/gim,themeLabel:/--theme-label\s*:\s*['"]([^'"]+)['"]/,themeIcon:/--theme-icon\s*:\s*['"]([^'"]+)['"]/,themeIsDark:/--theme-is-dark\s*:\s*(0|1)/}},xe={Inter:"inter-latin","Space Grotesk":"space-grotesk-latin","Playfair Display":"playfair-display-latin","Press Start 2P":"press-start-2p-latin",Roboto:"roboto-latin"},He=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],rt={base:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...Q.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...Q.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:Q.globalIgnore}}});import*as P from"node:fs";import"node:fs";import{createRequire as os}from"node:module";import{resolve as Ae,join as ce,dirname as pe,relative as at,normalize as ns,sep as it,extname as as}from"node:path";import{fileURLToPath as is}from"node:url";import ls from"fast-glob";function lt(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var ve,U,ct,O,q=je(()=>{"use strict";j();ve={getGlobOptionsFor:ke||void 0,SCAN_PATTERNS:Q||void 0,getPatternsFor:nt||void 0,I18N_PATHS:De||void 0},U={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};ct={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"},O=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._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,n._instance=this}normalizePath(e){if(!e)return"";try{return ns(e).split(it).join("/")}catch{return String(e).split(it).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=at(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(pe(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=os(ce(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 a=e.replace("@donotdev/",""),i=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(i))return i;if(["auth","billing","crud","oauth"].includes(a)){let l=this.resolveRepoPath(`packages/features/${a}`);if(this.pathExists(l))return l}if(a==="firebase"){let l=this.resolveRepoPath(`packages/providers/${a}`);if(this.pathExists(l))return l}}let r=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(r))return r;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=Ae(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=Ae(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=Ae(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=P.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:as(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await P.promises.readFile(e);let a=await P.promises.readFile(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&U.warn(`Failed to read file: ${e}`,a),null}}readSync(e,t={}){let{format:s="auto",encoding:r="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return P.readFileSync(e);let a=P.readFileSync(e,r),i=this.stripBom(a);return o==="json"?JSON.parse(i):i}catch(a){return this.options.debug&&U.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),u=this.normalizePath(pe(l)),c=this.pathExists(l);if(c&&!o)return i&&U.info(`Skipping existing file: ${l}`),!1;if(a)return U.info(`[DRY RUN] Would write file: ${l}`),!0;try{await P.promises.mkdir(u,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await lt(async()=>(Buffer.isBuffer(g)?await P.promises.writeFile(l,g):await P.promises.writeFile(l,g,"utf8"),i&&U.info(`${c?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:i=!1}=s,l=this.normalizePath(e),u=this.normalizePath(pe(l)),c=this.pathExists(l);if(c&&!o)return i&&U.info(`Skipping existing file: ${l}`),!1;if(a)return U.info(`[DRY RUN] Would write file: ${l}`),!0;try{P.mkdirSync(u,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let p=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:p==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?P.writeFileSync(l,g):P.writeFileSync(l,g,"utf8"),i&&U.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(d){throw new Error(`Failed to write file: ${l}: ${d instanceof Error?d.message:String(d)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&U.info(`Skipping existing file: ${i}`),!1;if(o)return U.info(`[DRY RUN] Would copy file: ${i}`),!0;let u=this.normalizePath(pe(i));try{await P.promises.mkdir(u,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await lt(async()=>(await P.promises.copyFile(e,i),a&&U.info(`${l?"Updated":"Created"} file: ${i}`),!0),`Failed to copy file from ${e} to ${i}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,i=this.normalizePath(t),l=this.pathExists(i);if(l&&!r)return a&&U.info(`Skipping existing file: ${i}`),!1;if(o)return U.info(`[DRY RUN] Would copy file: ${i}`),!0;let u=this.normalizePath(pe(i));try{P.mkdirSync(u,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return P.copyFileSync(e,i),a&&U.info(`${l?"Updated":"Created"} file: ${i}`),!0}catch{return!1}}pathExists(e,t=!1){try{return P.existsSync(e)}catch(s){return t||U.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 P.existsSync(t)||P.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return P.readdirSync(e,t)}catch(s){return this.options.debug&&U.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return P.statSync(e)}catch(t){return this.options.debug&&U.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return P.realpathSync(e)}watch(e,t,s){return P.watch(e,t,s)}lstatSync(e){try{return P.lstatSync(e)}catch(t){return this.options.debug&&U.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await P.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{P.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await P.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){P.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return P.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=ce(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(Ae(e)),s=this.getAppRoot(),r=at(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(ce(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),i=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:ve.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([i],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=ve.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),r=this.resolveFrameworkPackage("@donotdev/core");if(!r)return null;let o=this.normalizePath(ce(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await ls(e,t)).map(r=>{let o=typeof r=="string"?r:r.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 c of s)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let r=this.getAppRoot(),o=ve.getGlobOptionsFor?ve.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),i=e.framework.map(c=>{let p=this.normalizePath(c);return p.startsWith(a)?p.slice(a.length+1):p}),l=e.consumer.map(c=>{let p=this.normalizePath(c);return p.startsWith(a)?p.slice(a.length+1):p}),u={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let c=i.length>0?await this._globWithNormalization(i,u):[],p=await this._globWithNormalization(l,u);return{frameworkFiles:c,consumerFiles:p}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!ve.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 r=ve.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,u={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:o?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return u.all=[...u.eager,...u.lazy,...u.framework.eager,...u.framework.lazy],u}let a=r,i={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return i.all=[...i.consumer,...i.framework],i}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let s=pe(is(import.meta.url));return this.normalizePath(ce(s,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(ce(t,ct.TOOLING)),a=this.normalizePath(ce(t,ct.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let i=ce(t,"apps");if(this.pathExists(i)&&this.statSync(i)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(ce(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(pe(t))===t)return t;let u=this.normalizePath(pe(t));if(u===t)break;t=u,s++}return this.normalizePath(e)}}});var Ht={};Zt(Ht,{createDndevPlugin:()=>sr});import{execSync as Me,spawn as zs}from"node:child_process";function J(){return O.getInstance()}function Ut(){return J().getRepoRoot()}function Gt(){return J().resolveRepoPath(".dndev")}function y(n,e,t=200){n.writeHead(t,{"Content-Type":"application/json"}),n.end(JSON.stringify(e))}function Pe(n,e=js){return new Promise((t,s)=>{let r="",o=0;n.on("data",a=>{if(o+=a.length,o>e){n.destroy(),s(new Error("Request body too large"));return}r+=a.toString()}),n.on("end",()=>t(r)),n.on("error",s)})}function Us(n){let e=n.lastIndexOf(".");return e===-1?"":n.slice(e).toLowerCase()}function Gs(){let n=J(),e=[],t=process.env.HOME||process.env.USERPROFILE||"";try{let r=process.platform==="win32"?"where node":"which node",o=Me(r,{encoding:"utf8"}).trim().split(`
|
|
2
2
|
`)[0];e.push(o)}catch{}let s=[process.env.NVM_DIR,n.resolvePath(".nvm",t)].filter(Boolean);for(let r of s)try{let o=n.resolvePath("versions/node",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/bin/node`,o))}catch{}if(process.env.NVM_BIN&&e.push(n.resolvePath("node",process.env.NVM_BIN)),process.platform==="win32"){e.push("C:\\Program Files\\nodejs\\node.exe");let r=process.env.APPDATA||"";if(r)try{let o=n.resolvePath("nvm",r),a=n.readdirSync(o).filter(i=>i.startsWith("v")).sort().reverse();for(let i of a)e.push(n.resolvePath(`${i}/node.exe`,o))}catch{}}else e.push("/usr/local/bin/node","/usr/bin/node");for(let r of e)try{let o=n.realpathSync(r);if(o.includes("bun")||!n.pathExists(o))continue;return r}catch{continue}return"node"}function Wt(n){if(!n||typeof n!="string"||n.includes("\0"))return!1;let e=n.split(/[/\\]/).filter(Boolean);for(let t of e)if(t==="."||t===".."||t==="node_modules"||t===".git"||t.startsWith(".")&&t!==".dndev")return!1;return!0}function Ws(n){return n.includes("..")?!1:n.startsWith(".dndev/")||n.startsWith("docs/")||n.startsWith("guides/")}function Bt(n){let e=J(),t=e.getRepoRoot(),s=e.resolvePath(n,t),r=e.normalizePath(t),o=e.normalizePath(s);return!o.startsWith(r+"/")&&o!==r?null:s}async function Vs(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return y(e,{error:"path parameter required"},400);if(!Wt(s))return y(e,{error:"Access denied"},403);let r=Bt(s);if(!r)return y(e,{error:"Access denied"},403);let o=J();if(!o.pathExists(r))return y(e,{error:"File not found"},404);let a=Us(r);if(Bs.has(a)){let i=o.readSync(r,{format:"buffer"});return i?(e.writeHead(200,{"Content-Type":Vt[a]||"application/octet-stream","Content-Length":i.byteLength}),void e.end(Buffer.from(i))):y(e,{error:"Failed to read file"},500)}if(a===".json")try{let i=await o.read(r);return i===null?y(e,{error:"Failed to read file"},500):y(e,{path:s,content:i})}catch{return y(e,{error:"Invalid JSON"},500)}try{let i=await o.read(r,{format:"text"});if(i===null)return y(e,{error:"Failed to read file"},500);y(e,{path:s,content:i})}catch{y(e,{error:"Failed to read file"},500)}}function Hs(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("dir"),r=J(),o=r.getRepoRoot(),a=[],i=new Set(["node_modules",".git","dist","build",".next",".expo"]);function l(c,p){try{let g=r.readdirSync(c,{withFileTypes:!0});for(let d of g){let h=p?`${p}/${d.name}`:d.name;d.isDirectory()&&i.has(d.name)||(d.isDirectory()?(a.push({path:h,name:d.name,isDirectory:!0}),l(r.resolvePath(d.name,c),h)):d.name.endsWith(".md")&&a.push({path:h,name:d.name,isDirectory:!1}))}}catch{}}let u=[".dndev","docs","guides"];if(s){if(s.includes("..")||s.includes("\0"))return y(e,{error:"Access denied"},403);if(!u.includes(s)&&!u.some(d=>s.startsWith(d+"/")))return y(e,{error:"Directory not allowed"},403);let c=r.resolvePath(s,o),p=r.normalizePath(o);if(!r.normalizePath(c).startsWith(p+"/"))return y(e,{error:"Access denied"},403);r.pathExists(c)&&(a.push({path:s,name:r.getBasename(s),isDirectory:!0}),l(c,s))}else{for(let c of u){let p=r.resolveRepoPath(c);r.pathExists(p)&&(a.push({path:c,name:c,isDirectory:!0}),l(p,c))}try{let c=r.readdirSync(o,{withFileTypes:!0});for(let p of c)!p.isDirectory()&&p.name.endsWith(".md")&&a.push({path:p.name,name:p.name,isDirectory:!1})}catch{}}y(e,{entries:a})}async function Js(n,e){let s=new URL(n.url,`http://${n.headers.host}`).searchParams.get("path");if(!s)return y(e,{error:"path parameter required"},400);if(!Wt(s))return y(e,{error:"Access denied"},403);if(!Ws(s))return y(e,{error:"Write not allowed to this path"},403);let r=Bt(s);if(!r)return y(e,{error:"Access denied"},403);try{let o=await Pe(n),{content:a}=JSON.parse(o);if(a===void 0)return y(e,{error:"content field required"},400);let i=typeof a=="string"?a:JSON.stringify(a,null,2);await J().write(r,i,{overwrite:!0}),y(e,{ok:!0})}catch{y(e,{error:"Failed to write file"},500)}}async function qs(n,e){try{let t=await Pe(n),{line:s,checked:r}=JSON.parse(t);if(typeof s!="number")return y(e,{error:"line number required"},400);let o=J(),a=o.resolveRepoPath(".dndev/implementation.md");if(!o.pathExists(a))return y(e,{error:"implementation.md not found"},404);let i=await o.read(a,{format:"text"});if(i===null)return y(e,{error:"Failed to read file"},500);let l=i.split(`
|
|
3
3
|
`);if(s<0||s>=l.length)return y(e,{error:"Line out of range"},400);let u=l[s];l[s]=r?u.replace("- [ ]","- [x]"):u.replace("- [x]","- [ ]"),await o.write(a,l.join(`
|
|
4
4
|
`),{overwrite:!0}),y(e,{ok:!0,line:l[s]})}catch{y(e,{error:"Failed to update progress"},500)}}async function Ys(n,e){try{let t=await Pe(n),{id:s,data:r}=JSON.parse(t);if(!s||!r)return y(e,{error:"id and data required"},400);if(!/^[\w-]+$/.test(s))return y(e,{error:"Invalid screenshot ID"},400);let o=J(),a=o.resolveRepoPath(".dndev/bugs");o.ensureDirSync(a);let i=Buffer.from(r,"base64"),l=o.resolvePath(`${s}.png`,a);await o.write(l,i,{overwrite:!0}),y(e,{ok:!0,path:`.dndev/bugs/${s}.png`})}catch{y(e,{error:"Failed to save screenshot"},500)}}async function Ks(n,e){try{let t=await Pe(n),{action:s,phase:r}=JSON.parse(t);if(!s||typeof r!="number")return y(e,{error:"action and phase required"},400);let o=J(),a=Gt();o.ensureDirSync(a);let i=o.resolvePath("protocol.json",a),l={currentPhase:0,phases:{}};if(o.pathExists(i))try{let u=await o.read(i);u&&(l=u)}catch{}s==="start"?(l.currentPhase=r,l.phases[r]||(l.phases[r]={}),l.phases[r].status="active",l.phases[r].startedAt=new Date().toISOString()):s==="complete"&&(l.phases[r]||(l.phases[r]={}),l.phases[r].status="completed",l.phases[r].completedAt=new Date().toISOString()),await o.write(i,l,{overwrite:!0}),y(e,{ok:!0,protocol:l})}catch{y(e,{error:"Failed to update phase"},500)}}function Zs(n,e){try{let t=Ut(),s=Me("git rev-parse --short HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim(),r=Me("git rev-parse --abbrev-ref HEAD",{cwd:t,encoding:"utf-8",timeout:5e3}).trim();y(e,{commit:s,branch:r})}catch{y(e,{commit:"unknown",branch:"unknown"})}}async function Xs(n,e){try{let t=await Pe(n),s=JSON.parse(t);if(!s.id||!s.type||!s.result)return y(e,{error:"id, type, and result required"},400);let r=J(),o=Gt();r.ensureDirSync(o);let a=r.resolvePath("health.json",o),i={actions:[]};if(r.pathExists(a))try{let u=await r.read(a);u&&(i=u)}catch{}Array.isArray(i.actions)||(i.actions=[]);let l=i.actions.findIndex(u=>u.id===s.id);l>=0?i.actions[l]={...i.actions[l],...s}:i.actions.unshift(s),await r.write(a,i,{overwrite:!0}),y(e,{ok:!0})}catch{y(e,{error:"Failed to append action"},500)}}function Qs(n,e){let t=J(),s=t.resolveRepoPath("apps");try{let o=t.readdirSync(s).filter(a=>{if(a==="dndev")return!1;let i=t.resolvePath(a,s);return t.statSync(i)?.isDirectory()&&t.pathExists(t.resolvePath("package.json",i))}).map(a=>{try{let i=t.resolvePath(`${a}/package.json`,s),l=t.readSync(i);return{name:a,packageName:l?.name||a}}catch{return{name:a,packageName:a}}});y(e,{apps:o})}catch{y(e,{apps:[]})}}function er(n){if(Ze)return;let e=J(),t=e.normalizePath(n.config.root),s=e.resolvePath("terminal-sidecar.cjs",t);if(!e.pathExists(s))return;try{let i=Me(`fuser ${jt}/tcp 2>/dev/null`,{encoding:"utf8"}).trim();i&&process.kill(Number(i),"SIGKILL")}catch{}Ze=!0;let r=e.getRepoRoot(),o=Gs(),a=zs(o,[s],{cwd:r,stdio:["ignore","inherit","inherit","ipc"],env:{...process.env,TERMINAL_PORT:String(jt),TERMINAL_CWD:r}});a.on("message",i=>{i.type}),a.on("exit",i=>{Ze=!1}),process.on("exit",()=>{a.kill()})}function tr(n){let e=J(),t=e.getRepoRoot(),s=[".dndev","docs","guides"];for(let r of s){let o=e.resolveRepoPath(r);if(!e.pathExists(o))continue;let a=e.watch(o,{recursive:!0},(i,l)=>{if(!l||l==="dashboard.json")return;let u=`${r}/${l}`,c=`change:${u}`;Xe.has(c)||(Xe.set(c,!0),setTimeout(()=>Xe.delete(c),300),n.hot.send("dndev:file-changed",{path:u,timestamp:Date.now()}))});n.httpServer?.on("close",()=>a.close())}}function sr(n={}){return{name:"dndev",configureServer(e){let t=Ut();n.debug,e.middlewares.use((s,r,o)=>{let a=s.url;if(!a?.startsWith(zt))return o();let l=new URL(a,`http://${s.headers.host}`).pathname.slice(zt.length),u=s.method?.toUpperCase();if(u==="GET")return l==="/file"?void Vs(s,r):l==="/tree"?void Hs(s,r):l==="/git/head"?void Zs(s,r):l==="/apps"?void Qs(s,r):y(r,{error:"Not found"},404);if(u==="POST")return l==="/file"?void Js(s,r):l==="/progress/toggle"?void qs(s,r):l==="/bugs/screenshot"?void Ys(s,r):l==="/phase"?void Ks(s,r):l==="/actions/append"?void Xs(s,r):y(r,{error:"Not found"},404);y(r,{error:"Method not allowed"},405)}),er(e),tr(e)}}}var zt,js,Vt,Bs,jt,Ze,Xe,Jt=je(()=>{"use strict";q();zt="/api/dndev";js=5*1024*1024;Vt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".svg":"image/svg+xml"},Bs=new Set(Object.keys(Vt));jt=24681,Ze=!1;Xe=new Map});import us from"@rollup/plugin-strip";import{visualizer as ps}from"rollup-plugin-visualizer";var Ue=["/react/","/react-dom/","/scheduler/","/react-router","/@radix-ui/","/react-day-picker/","/react-hook-form/","/react-i18next/","/clsx/","/class-variance-authority/"],Xt={valibot:["/valibot/"],firebase:["/firebase/","/@firebase/"],lucide:["/lucide-react/","/lucide/"],i18n:["/i18next/","/i18next-browser-languagedetector/","/i18next-http-backend/","/@donotdev/i18n/"],zustand:["/zustand/"],"tanstack-query":["/@tanstack/react-query/","/@tanstack/query-core/"]};function Qt(n){let e=n.match(/(?:^|\0)virtual:([^?]+)/);if(e)return e[1]}function et(n){let e=n.replace(/\\/g,"/");if(e.includes("/node_modules/"))return e.split("?")[0]}function tt(n,e=Ue){return e.some(t=>n.includes(t))}function es(n){for(let[e,t]of Object.entries(Xt))if(t.some(s=>n.includes(s)))return e}function ts(n){let e=Qt(n);if(e)return e==="i18n-mapping"?"virtual-i18n-mapping":"virtual-modules";let t=et(n);if(!t)return;if(tt(t))return"react-core";let s=es(t);if(s)return s}function ss(n=[]){let e=n.filter(s=>!Ue.includes(s)),t=[...Ue,...e];return function(s){let r=et(s);if(r&&tt(r,t))return"react-core"}}var Qe={development:{manualChunks:void 0},production:{manualChunks:ts}};function st(n,e={}){let t=Qe[n]||Qe.production,s=e.reactCore||[];return s.length>0?{manualChunks:ss(s)}:t}q();import*as Y from"@clack/prompts";var re={reset:"\x1B[0m",green:"\x1B[32m",brightGreen:"\x1B[92m",red:"\x1B[31m",brightRed:"\x1B[91m",yellow:"\x1B[33m",brightYellow:"\x1B[93m",blue:"\x1B[34m",cyan:"\x1B[36m",brightCyan:"\x1B[96m",gray:"\x1B[90m",white:"\x1B[37m"};function cs(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function ae(n,e){return cs()?`${e}${n}${re.reset}`:n}function T(n,e,t,s={}){let{logDir:r=".dndev-logs",fileLogging:o=!1}=s,a=O.getInstance(),i=null;if(o){let c=a.resolveAppPath(r);a.pathExists(c)||a.mkdir(c),i=a.resolveAppPath(`${r}/${n.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let p=`=== ${n} Log Started at ${new Date().toISOString()} ===
|