@donotdev/core 0.1.44 → 0.1.45
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 +9 -0
- package/next/index.d.ts +9 -0
- package/next/index.js +27 -14
- package/package.json +1 -1
- package/server.d.ts +9 -0
- package/vite/index.d.ts +9 -0
package/index.d.ts
CHANGED
|
@@ -2652,6 +2652,15 @@ interface AppConfig {
|
|
|
2652
2652
|
features?: FeaturesConfig;
|
|
2653
2653
|
/** Query cache configuration (defaults: 5min staleTime, refetch on focus/reconnect) */
|
|
2654
2654
|
query?: QueryConfig;
|
|
2655
|
+
/**
|
|
2656
|
+
* Server-side rendering (Next adapter). **Defaults to `true`** — generated page
|
|
2657
|
+
* wrappers render directly and the provider tree renders on the server, so page
|
|
2658
|
+
* content is present in the initial HTML (real, crawlable SSR). Set to `false`
|
|
2659
|
+
* to opt OUT and restore the legacy client-only render (content appears only
|
|
2660
|
+
* after hydration). The provider tree is store-driven, so SSR routes render
|
|
2661
|
+
* dynamically at request time.
|
|
2662
|
+
*/
|
|
2663
|
+
ssr?: boolean;
|
|
2655
2664
|
}
|
|
2656
2665
|
/**
|
|
2657
2666
|
* Custom store configuration for app-specific stores
|
package/next/index.d.ts
CHANGED
|
@@ -649,6 +649,15 @@ interface AppConfig {
|
|
|
649
649
|
features?: FeaturesConfig;
|
|
650
650
|
/** Query cache configuration (defaults: 5min staleTime, refetch on focus/reconnect) */
|
|
651
651
|
query?: QueryConfig;
|
|
652
|
+
/**
|
|
653
|
+
* Server-side rendering (Next adapter). **Defaults to `true`** — generated page
|
|
654
|
+
* wrappers render directly and the provider tree renders on the server, so page
|
|
655
|
+
* content is present in the initial HTML (real, crawlable SSR). Set to `false`
|
|
656
|
+
* to opt OUT and restore the legacy client-only render (content appears only
|
|
657
|
+
* after hydration). The provider tree is store-driven, so SSR routes render
|
|
658
|
+
* dynamically at request time.
|
|
659
|
+
*/
|
|
660
|
+
ssr?: boolean;
|
|
652
661
|
}
|
|
653
662
|
|
|
654
663
|
/**
|
package/next/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import*as b from"node:fs";import"node:fs";import{createRequire as bs}from"node:module";import{resolve as ge,join as X,dirname as Z,relative as ot,normalize as ys,sep as nt,extname as ws}from"node:path";import{fileURLToPath as Ps}from"node:url";import Ss from"fast-glob";var pe={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"};var Ee={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env",blog:"@donotdev/blog-content"},U={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},D={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",configEnv:"src/config/dndev-config-env.js",configServer:"src/config/dndev-config-server.js",blogContent:"src/content/blog/blog-content.generated.ts"},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"}},Ce={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},ue={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},ve={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"},z={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:[`${ve.SOURCE_EAGER}/*_*.json`],lazy:[`${ve.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/**"]},be={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","zustand/middleware","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async"],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"]},st=["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"];var Ne={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)/}};var oe={inter:[300,400,600,700],"playfair-display":[400,500,600,700],roboto:[400,700],"space-grotesk":[300,400,500,600,700],"press-start-2p":[400]},ye={en:["latin"],fr:["latin"],es:["latin"],de:["latin"],it:["latin"],pt:["latin"],nl:["latin"],da:["latin"],sv:["latin"],nb:["latin"],fi:["latin"],pl:["latin"],cs:["latin"],sk:["latin"],hr:["latin"],sl:["latin"],hu:["latin"],ro:["latin"],et:["latin"],lv:["latin"],lt:["latin"],mt:["latin"],ga:["latin"],ca:["latin"],eu:["latin"],gl:["latin"],af:["latin"],sw:["latin"],tr:["latin"],id:["latin"],ms:["latin"],tl:["latin"],vi:["latin","vietnamese"],ru:["latin","cyrillic"],bg:["latin","cyrillic"],uk:["latin","cyrillic"],sr:["latin","cyrillic"],mk:["latin","cyrillic"],be:["latin","cyrillic"],el:["latin","greek"],zh:[],ja:[],ko:[],ar:[],he:[],th:[],hi:[],bn:[],ta:[]},Fe=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],tt={base:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...z.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...z.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore}};function rt(i,e=null){let t=z[i];if(!t)throw new Error(`Unknown pattern type: ${i}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function we(i){return tt[i]||tt.base}var ne={getGlobOptionsFor:we||void 0,SCAN_PATTERNS:z||void 0,getPatternsFor:rt||void 0,I18N_PATHS:ve||void 0},A={error:(i,e)=>{},warn:(i,e)=>{},info:i=>{}};function at(i,e){return i().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var it={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"},y=class i{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return i._instance||(i._instance=new i(e)),i._instance}static _reset(){i._instance=null}constructor(e={}){if(i._instance)return i._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,i._instance=this}normalizePath(e){if(!e)return"";try{return ys(e).split(nt).join("/")}catch{return String(e).split(nt).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=ot(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(Z(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=bs(X(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/",""),n=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(n))return n;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=ge(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=ge(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=ge(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=b.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:ws(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 b.promises.readFile(e);let a=await b.promises.readFile(e,r),n=this.stripBom(a);return o==="json"?JSON.parse(n):n}catch(a){return this.options.debug&&A.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 b.readFileSync(e);let a=b.readFileSync(e,r),n=this.stripBom(a);return o==="json"?JSON.parse(n):n}catch(a){return this.options.debug&&A.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:n=!1}=s,l=this.normalizePath(e),p=this.normalizePath(Z(l)),c=this.pathExists(l);if(c&&!o)return n&&A.info(`Skipping existing file: ${l}`),!1;if(a)return A.info(`[DRY RUN] Would write file: ${l}`),!0;try{await b.promises.mkdir(p,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let u=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:u==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await at(async()=>(Buffer.isBuffer(g)?await b.promises.writeFile(l,g):await b.promises.writeFile(l,g,"utf8"),n&&A.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:n=!1}=s,l=this.normalizePath(e),p=this.normalizePath(Z(l)),c=this.pathExists(l);if(c&&!o)return n&&A.info(`Skipping existing file: ${l}`),!1;if(a)return A.info(`[DRY RUN] Would write file: ${l}`),!0;try{b.mkdirSync(p,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let u=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:u==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?b.writeFileSync(l,g):b.writeFileSync(l,g,"utf8"),n&&A.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(f){throw new Error(`Failed to write file: ${l}: ${f instanceof Error?f.message:String(f)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,n=this.normalizePath(t),l=this.pathExists(n);if(l&&!r)return a&&A.info(`Skipping existing file: ${n}`),!1;if(o)return A.info(`[DRY RUN] Would copy file: ${n}`),!0;let p=this.normalizePath(Z(n));try{await b.promises.mkdir(p,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await at(async()=>(await b.promises.copyFile(e,n),a&&A.info(`${l?"Updated":"Created"} file: ${n}`),!0),`Failed to copy file from ${e} to ${n}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,n=this.normalizePath(t),l=this.pathExists(n);if(l&&!r)return a&&A.info(`Skipping existing file: ${n}`),!1;if(o)return A.info(`[DRY RUN] Would copy file: ${n}`),!0;let p=this.normalizePath(Z(n));try{b.mkdirSync(p,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return b.copyFileSync(e,n),a&&A.info(`${l?"Updated":"Created"} file: ${n}`),!0}catch{return!1}}pathExists(e,t=!1){try{return b.existsSync(e)}catch(s){return t||A.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 b.existsSync(t)||b.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return b.readdirSync(e,t)}catch(s){return this.options.debug&&A.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return b.statSync(e)}catch(t){return this.options.debug&&A.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return b.realpathSync(e)}watch(e,t,s){return b.watch(e,t,s)}lstatSync(e){try{return b.lstatSync(e)}catch(t){return this.options.debug&&A.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await b.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{b.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await b.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){b.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return b.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=X(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(ge(e)),s=this.getAppRoot(),r=ot(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(X(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),n=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:ne.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([n],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=ne.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(X(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await Ss(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=ne.getGlobOptionsFor?ne.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),n=e.framework.map(c=>{let u=this.normalizePath(c);return u.startsWith(a)?u.slice(a.length+1):u}),l=e.consumer.map(c=>{let u=this.normalizePath(c);return u.startsWith(a)?u.slice(a.length+1):u}),p={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let c=n.length>0?await this._globWithNormalization(n,p):[],u=await this._globWithNormalization(l,p);return{frameworkFiles:c,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!ne.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=ne.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,p={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 p.all=[...p.eager,...p.lazy,...p.framework.eager,...p.framework.lazy],p}let a=r,n={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return n.all=[...n.consumer,...n.framework],n}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=Z(Ps(import.meta.url));return this.normalizePath(ge(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(X(t,it.TOOLING)),a=this.normalizePath(X(t,it.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let n=X(t,"apps");if(this.pathExists(n)&&this.statSync(n)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(X(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(Z(t))===t)return t;let p=this.normalizePath(Z(t));if(p===t)break;t=p,s++}return this.normalizePath(e)}};function lt({logger:i,debug:e=!1}={}){let t=y.getInstance(),s=!1,r=null;if(process.env.DNDEV_APP_ROOT?(r=t.normalizePath(process.env.DNDEV_APP_ROOT),t.pathExists(r)?(t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root set from DNDEV_APP_ROOT: ${r}`)):i&&i.warn(`DNDEV_APP_ROOT path does not exist: ${r}`)):e&&i&&i.debug("DNDEV_APP_ROOT env var not set"),!s){if(t.getRepoRoot()){let a=t.resolveRepoPath("apps");if(t.pathExists(a))try{let n=process.cwd(),l=t.normalizePath(n);if(l.includes("/apps/")){let p=l.indexOf("/apps/"),u=l.substring(p+6).split("/")[0];if(u){let g=t.resolveRepoPath(`apps/${u}`),f=t.resolveRepoPath(`apps/${u}/next.config.js`);t.pathExists(f)&&(r=g,t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root detected from process.cwd(): ${r}`))}}}catch{}}!s&&!r&&(r=process.cwd(),t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root fallback to process.cwd(): ${r}`))}return{appRoot:r,appRootSet:s}}import mt from"node:fs";function ct(i){let e=new Set(Object.keys(oe)),t=new Set(["latin"]);for(let o of i||[]){let a=ye[o];if(a)for(let n of a)t.add(n)}let s=[],r=new Set;for(let o of e){let a=oe[o];for(let n of t)for(let l of a){let p=`@fontsource/${o}/${n}-${l}.css`,c=`${o}-${n}-${l}-normal`;s.push(p),r.add(c)}}return{imports:s,stems:r,subsets:t,fontStems:e}}function De(i){return i.replace(/,\s*url\([^)]*\.woff\)\s*format\(['"]woff['"]\)/g,"")}import*as T from"@clack/prompts";var W={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 $s(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function J(i,e){return $s()?`${e}${i}${W.reset}`:i}function C(i,e,t,s={}){let{logDir:r=".dndev-logs",fileLogging:o=!1}=s,a=y.getInstance(),n=null;if(o){let c=a.resolveAppPath(r);a.pathExists(c)||a.mkdir(c),n=a.resolveAppPath(`${r}/${i.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let u=`=== ${i} Log Started at ${new Date().toISOString()} ===
|
|
1
|
+
import*as b from"node:fs";import"node:fs";import{createRequire as bs}from"node:module";import{resolve as ge,join as X,dirname as Z,relative as ot,normalize as ys,sep as nt,extname as ws}from"node:path";import{fileURLToPath as Ps}from"node:url";import $s from"fast-glob";var pe={HOMEPAGE_FILE:"HomePage.tsx",HOMEPAGE_PATH:"/",HOMEPAGE_COMPONENT:"HomePage"};var Ee={routes:"virtual:routes",themes:"virtual:themes",i18n:"virtual:i18n-mapping",assets:"virtual:assets",env:"virtual:env",blog:"@donotdev/blog-content"},U={routes:"routes",themes:"themes",i18n:"i18n",assets:"assets",env:"env"},D={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",configEnv:"src/config/dndev-config-env.js",configServer:"src/config/dndev-config-server.js",blogContent:"src/content/blog/blog-content.generated.ts"},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"}},Ce={package:"@donotdev/ui",assetsPath:"packages/ui/assets",browserTargets:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"]},ue={public:"public",fonts:"fonts",nodeModules:"node_modules",packages:"packages",core:"core",ui:"ui"},ve={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"},z={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:[`${ve.SOURCE_EAGER}/*_*.json`],lazy:[`${ve.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/**"]},be={mandatoryIncludes:["react","react-dom","react-router-dom","zustand","zustand/middleware","lucide-react","valibot","i18next","i18next-browser-languagedetector","i18next-http-backend","react-i18next","@tanstack/react-query","react-helmet-async"],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"]},st=["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"];var Ne={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)/}};var oe={inter:[300,400,600,700],"playfair-display":[400,500,600,700],roboto:[400,700],"space-grotesk":[300,400,500,600,700],"press-start-2p":[400]},ye={en:["latin"],fr:["latin"],es:["latin"],de:["latin"],it:["latin"],pt:["latin"],nl:["latin"],da:["latin"],sv:["latin"],nb:["latin"],fi:["latin"],pl:["latin"],cs:["latin"],sk:["latin"],hr:["latin"],sl:["latin"],hu:["latin"],ro:["latin"],et:["latin"],lv:["latin"],lt:["latin"],mt:["latin"],ga:["latin"],ca:["latin"],eu:["latin"],gl:["latin"],af:["latin"],sw:["latin"],tr:["latin"],id:["latin"],ms:["latin"],tl:["latin"],vi:["latin","vietnamese"],ru:["latin","cyrillic"],bg:["latin","cyrillic"],uk:["latin","cyrillic"],sr:["latin","cyrillic"],mk:["latin","cyrillic"],be:["latin","cyrillic"],el:["latin","greek"],zh:[],ja:[],ko:[],ar:[],he:[],th:[],hi:[],bn:[],ta:[]},Fe=[{name:"light",displayName:"Light",icon:"Sun",isDark:!1}],tt={base:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...z.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...z.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:z.globalIgnore}};function rt(i,e=null){let t=z[i];if(!t)throw new Error(`Unknown pattern type: ${i}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function we(i){return tt[i]||tt.base}var ne={getGlobOptionsFor:we||void 0,SCAN_PATTERNS:z||void 0,getPatternsFor:rt||void 0,I18N_PATHS:ve||void 0},A={error:(i,e)=>{},warn:(i,e)=>{},info:i=>{}};function at(i,e){return i().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var it={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"},y=class i{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return i._instance||(i._instance=new i(e)),i._instance}static _reset(){i._instance=null}constructor(e={}){if(i._instance)return i._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,i._instance=this}normalizePath(e){if(!e)return"";try{return ys(e).split(nt).join("/")}catch{return String(e).split(nt).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=ot(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(Z(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=bs(X(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/",""),n=this.resolveRepoPath(`packages/${a}`);if(this.pathExists(n))return n;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=ge(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),r=ge(t,s);return this.normalizePath(r)}resolvePath(e,t){let s=this.normalizePath(t),r=this.normalizePath(e),o=ge(s,r);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=b.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:ws(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 b.promises.readFile(e);let a=await b.promises.readFile(e,r),n=this.stripBom(a);return o==="json"?JSON.parse(n):n}catch(a){return this.options.debug&&A.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 b.readFileSync(e);let a=b.readFileSync(e,r),n=this.stripBom(a);return o==="json"?JSON.parse(n):n}catch(a){return this.options.debug&&A.warn(`Failed to read file: ${e}`,a),null}}async write(e,t,s={}){let{format:r="auto",overwrite:o=!1,dryRun:a=!1,verbose:n=!1}=s,l=this.normalizePath(e),p=this.normalizePath(Z(l)),c=this.pathExists(l);if(c&&!o)return n&&A.info(`Skipping existing file: ${l}`),!1;if(a)return A.info(`[DRY RUN] Would write file: ${l}`),!0;try{await b.promises.mkdir(p,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let u=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:u==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await at(async()=>(Buffer.isBuffer(g)?await b.promises.writeFile(l,g):await b.promises.writeFile(l,g,"utf8"),n&&A.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:n=!1}=s,l=this.normalizePath(e),p=this.normalizePath(Z(l)),c=this.pathExists(l);if(c&&!o)return n&&A.info(`Skipping existing file: ${l}`),!1;if(a)return A.info(`[DRY RUN] Would write file: ${l}`),!0;try{b.mkdirSync(p,{recursive:!0})}catch(f){if(f?.code!=="EEXIST")throw f}let u=this._detectFormat(e,r),g;Buffer.isBuffer(t)?g=t:u==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return Buffer.isBuffer(g)?b.writeFileSync(l,g):b.writeFileSync(l,g,"utf8"),n&&A.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(f){throw new Error(`Failed to write file: ${l}: ${f instanceof Error?f.message:String(f)}`)}}async copy(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,n=this.normalizePath(t),l=this.pathExists(n);if(l&&!r)return a&&A.info(`Skipping existing file: ${n}`),!1;if(o)return A.info(`[DRY RUN] Would copy file: ${n}`),!0;let p=this.normalizePath(Z(n));try{await b.promises.mkdir(p,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await at(async()=>(await b.promises.copyFile(e,n),a&&A.info(`${l?"Updated":"Created"} file: ${n}`),!0),`Failed to copy file from ${e} to ${n}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:r=!1,dryRun:o=!1,verbose:a=!1}=s,n=this.normalizePath(t),l=this.pathExists(n);if(l&&!r)return a&&A.info(`Skipping existing file: ${n}`),!1;if(o)return A.info(`[DRY RUN] Would copy file: ${n}`),!0;let p=this.normalizePath(Z(n));try{b.mkdirSync(p,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return b.copyFileSync(e,n),a&&A.info(`${l?"Updated":"Created"} file: ${n}`),!0}catch{return!1}}pathExists(e,t=!1){try{return b.existsSync(e)}catch(s){return t||A.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 b.existsSync(t)||b.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return b.readdirSync(e,t)}catch(s){return this.options.debug&&A.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return b.statSync(e)}catch(t){return this.options.debug&&A.warn(`Failed to stat file: ${e}`,t),null}}realpathSync(e){return b.realpathSync(e)}watch(e,t,s){return b.watch(e,t,s)}lstatSync(e){try{return b.lstatSync(e)}catch(t){return this.options.debug&&A.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await b.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{b.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await b.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){b.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return b.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=X(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(ge(e)),s=this.getAppRoot(),r=ot(s,t),o=this.normalizePath(r);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let r=this.normalizePath(X(e,t)),o=this.getAppRoot(),a=this.normalizePath(o),n=r.startsWith(a)?r.slice(a.length+1):r,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:ne.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([n],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=ne.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(X(r,t.PUBLISHED_ROOT,s)),a=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(a),o}async _globWithNormalization(e,t){return(await $s(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=ne.getGlobOptionsFor?ne.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},a=this.normalizePath(r),n=e.framework.map(c=>{let u=this.normalizePath(c);return u.startsWith(a)?u.slice(a.length+1):u}),l=e.consumer.map(c=>{let u=this.normalizePath(c);return u.startsWith(a)?u.slice(a.length+1):u}),p={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:r};try{let c=n.length>0?await this._globWithNormalization(n,p):[],u=await this._globWithNormalization(l,p);return{frameworkFiles:c,consumerFiles:u}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!ne.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=ne.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=r,p={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 p.all=[...p.eager,...p.lazy,...p.framework.eager,...p.framework.lazy],p}let a=r,n={framework:o?(a.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(a.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return n.all=[...n.consumer,...n.framework],n}getEmptyModulePath(){return this.getEmptyCjsModulePath().replace(/\.cjs$/,".js")}getEmptyFlagModulePath(){let e=Z(Ps(import.meta.url));return this.normalizePath(ge(e,"emptyFlag.js"))}getEmptyCjsModulePath(){let e=this.resolvePackage("@donotdev/core/empty");if(!e)throw new Error("Cannot resolve @donotdev/core/empty \u2014 package setup is broken");return e}_findRepoRoot(e){let t=this.normalizePath(e),s=0,r=this.options.maxLevels;for(;s<r;){let o=this.normalizePath(X(t,it.TOOLING)),a=this.normalizePath(X(t,it.CORE));if(this.pathExists(o)&&this.pathExists(a))return t;let n=X(t,"apps");if(this.pathExists(n)&&this.statSync(n)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(X(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(Z(t))===t)return t;let p=this.normalizePath(Z(t));if(p===t)break;t=p,s++}return this.normalizePath(e)}};function lt({logger:i,debug:e=!1}={}){let t=y.getInstance(),s=!1,r=null;if(process.env.DNDEV_APP_ROOT?(r=t.normalizePath(process.env.DNDEV_APP_ROOT),t.pathExists(r)?(t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root set from DNDEV_APP_ROOT: ${r}`)):i&&i.warn(`DNDEV_APP_ROOT path does not exist: ${r}`)):e&&i&&i.debug("DNDEV_APP_ROOT env var not set"),!s){if(t.getRepoRoot()){let a=t.resolveRepoPath("apps");if(t.pathExists(a))try{let n=process.cwd(),l=t.normalizePath(n);if(l.includes("/apps/")){let p=l.indexOf("/apps/"),u=l.substring(p+6).split("/")[0];if(u){let g=t.resolveRepoPath(`apps/${u}`),f=t.resolveRepoPath(`apps/${u}/next.config.js`);t.pathExists(f)&&(r=g,t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root detected from process.cwd(): ${r}`))}}}catch{}}!s&&!r&&(r=process.cwd(),t.setAppRoot(r),s=!0,e&&i&&i.debug(`App root fallback to process.cwd(): ${r}`))}return{appRoot:r,appRootSet:s}}import mt from"node:fs";function ct(i){let e=new Set(Object.keys(oe)),t=new Set(["latin"]);for(let o of i||[]){let a=ye[o];if(a)for(let n of a)t.add(n)}let s=[],r=new Set;for(let o of e){let a=oe[o];for(let n of t)for(let l of a){let p=`@fontsource/${o}/${n}-${l}.css`,c=`${o}-${n}-${l}-normal`;s.push(p),r.add(c)}}return{imports:s,stems:r,subsets:t,fontStems:e}}function De(i){return i.replace(/,\s*url\([^)]*\.woff\)\s*format\(['"]woff['"]\)/g,"")}import*as T from"@clack/prompts";var W={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 Ss(){return process.env.NO_COLOR?!1:process.platform==="win32"?!0:process.stdout.isTTY===!0}function J(i,e){return Ss()?`${e}${i}${W.reset}`:i}function C(i,e,t,s={}){let{logDir:r=".dndev-logs",fileLogging:o=!1}=s,a=y.getInstance(),n=null;if(o){let c=a.resolveAppPath(r);a.pathExists(c)||a.mkdir(c),n=a.resolveAppPath(`${r}/${i.replace(/[^a-zA-Z0-9]/g,"-")}.log`);let u=`=== ${i} Log Started at ${new Date().toISOString()} ===
|
|
2
2
|
`;a.writeSync(n,u)}let l=(c,u,g)=>{if(n){let f=new Date().toISOString(),h=g.length>0?" "+g.map(m=>typeof m=="object"?JSON.stringify(m,null,2):String(m)).join(" "):"",d=`${f} [${c}] ${u}${h}
|
|
3
|
-
`;a.appendFile(n,d)}},p=(c,u)=>{if(u.length===0)return c;let g=u.map(f=>typeof f=="object"?JSON.stringify(f,null,2):String(f)).join(" ");return`${c} ${g}`};return{debug:(c,...u)=>{e&&(o?l("DEBUG",c,u):T.log.message(J(p(c,u),W.gray)))},verbose:(c,...u)=>{t&&(o?l("VERBOSE",c,u):T.log.message(p(c,u)))},info:(c,...u)=>{o?l("INFO",c,u):T.log.info(J(p(c,u),W.brightCyan))},warn:(c,...u)=>{e&&o?l("WARN",c,u):T.log.warn(J(p(c,u),W.brightYellow))},error:(c,...u)=>{e&&o?l("ERROR",c,u):T.log.error(J(p(c,u),W.brightRed))},success:(c,...u)=>{e&&o?l("SUCCESS",c,u):T.log.success(J(p(c,u),W.brightGreen))},when:(c,u="debug")=>(g,...f)=>{if(c){let h=p(g,f);switch(u){case"verbose":t&&(T.log.message(h),l("VERBOSE",g,f));break;case"info":T.log.info(J(h,W.brightCyan)),l("INFO",g,f);break;case"warn":T.log.warn(J(h,W.brightYellow)),l("WARN",g,f);break;case"error":T.log.error(J(h,W.brightRed)),l("ERROR",g,f);break;case"success":T.log.success(J(h,W.brightGreen)),l("SUCCESS",g,f);break;default:e&&(T.log.message(J(h,W.gray)),l("DEBUG",g,f))}}},getLogFilePath:()=>n}}var G=class i{constructor(e,t={}){if(this.constructor===i)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...t},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=C(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let r=await this._scanFiles(s),o=await this._processFiles(r);this.cache={...o,timestamp:Date.now()};let a=Date.now()-t;return this.logger.debug(`Discovery completed in ${a}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(e){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(e){let t=this._getPatternType();return await this.pathResolver.resolveFiles(e,t)}_extractFileNameInfo(e){let t=e.split("/"),s=t[t.length-1],r=s.split(".")[0],o=s.split(".").pop();return{fileName:s,baseName:r,extension:o,directory:t.slice(0,-1).join("/")}}async _processSingleFile(e,t){try{let s=this.pathResolver.getFileInfo(e);return s?await t(s):(this.logger.debug(`Could not get file info: ${e}`),null)}catch(s){return this.logger.debug(`Error processing file ${e}: ${s.message}`),null}}async _batchProcessFiles(e,t){return(await Promise.all(e.map(r=>this._processSingleFile(r,t)))).filter(r=>r!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};function xs(i){if(!i)return[];let e=y.getInstance(),t=new Set;try{let s=e.resolvePackage("@donotdev/core",i);if(!s)return[];let r=e.getDirname(e.getDirname(s)),o;try{o=e.readdirSync(r)}catch{return[]}for(let a of o)try{let n=e.resolvePath(`${a}/package.json`,r),l=e.readSync(n,{format:"json"});if(!l?.peerDependenciesMeta)continue;for(let[p,c]of Object.entries(l.peerDependenciesMeta))c?.optional&&t.add(p)}catch{}}catch{}return Array.from(t)}function Rs(i){if(!i)return[];let e=y.getInstance();try{let t=e.resolvePath("package.json",i),s=e.readSync(t,{format:"json"});if(!s)return[];let r=new Set;if(s.peerDependenciesMeta)for(let[o,a]of Object.entries(s.peerDependenciesMeta))a?.optional&&r.add(o);if(s.optionalDependencies)for(let o of Object.keys(s.optionalDependencies))r.add(o);return Array.from(r)}catch{return[]}}function ks(i){let e=be.optionalFeatures||[],t=xs(i),s=Rs(i);return[...new Set([...e,...t,...s])]}function _s(i){let e=y.getInstance();try{let t=e.resolvePath("package.json",i),s=e.readSync(t,{format:"json"});return s?new Set([...Object.keys(s.dependencies||{}),...Object.keys(s.devDependencies||{})]):new Set}catch{return new Set}}function As(i,e,t){if(t.resolvePackage(i,e||void 0))return!0;let s=i.startsWith("@")?i.split("/").slice(0,2).join("/"):i.split("/")[0],r=e;for(let o=0;o<10;o++){let a=t.resolvePath(`node_modules/${s}`,r);if(t.pathExists(a))return!0;let n=t.getDirname(r);if(n===r)break;r=n}return!1}function Pe(i){let e=ks(i),t=[],s=[],r=y.getInstance(),o=_s(i);for(let a of e)a.startsWith("@donotdev/")?o.has(a)?s.push(a):t.push(a):o.has(a)&&As(a,i,r)?s.push(a):t.push(a);return{missing:t,installed:s}}var ae=class i extends G{static LANGUAGE_FLAG_OVERRIDES={en:"gb","en-ca":"ca","es-ar":"ar","fr-be":"be",ar:"sa","ar-ma":"ma","ar-dz":"dz","ar-tn":"tn","ar-ly":"ly","ar-mr":"mr",hi:"in",sl:"si",uk:"ua",ga:"ie",gd:"gb-sct",br:"bzh",co:"fr-cor",am:"et",bn:"bd",gu:"in",kn:"in",ml:"in",mr:"in",ne:"np",pa:"pk",ta:"in",te:"in",ur:"pk",fa:"ir",kk:"kz",ky:"kg",tg:"tj",my:"mm",km:"kh",lo:"la",ka:"ge",hy:"am",be:"by",bs:"ba",sq:"al",ms:"my"};constructor(e,t={}){super(e,{fallbackLanguage:"en",additionalPaths:[],...t})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!t||t===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${t}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${t}, repoRoot=${s}`);let r=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${r.eager.length}, lazy: ${r.lazy.length}, framework eager: ${r.framework?.eager?.length||0}, framework lazy: ${r.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let o=we("i18n"),a=r.eager||[],n=r.lazy||[],l=(this.options.additionalPaths||[]).map(v=>{let P=v.endsWith(".json")?v:`${v}/*_*.json`;return this.pathResolver.resolveAppPath(P)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let p=r.framework?.eager||[],c=r.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${a.join(", ")}, lazy: ${n.join(", ")}, framework eager: ${p.join(", ")}, framework lazy: ${c.join(", ")}`),p.length===0&&c.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let u=this.pathResolver.normalizePath(t),g=this.pathResolver.normalizePath(s),f=(v,P)=>{let R=this.pathResolver.normalizePath(v),x=this.pathResolver.normalizePath(P);return R.startsWith(x)?R.slice(x.length+1):R},h=a.map(v=>f(v,t)),m=[...n,...l].map(v=>f(v,t)),S=p.map(v=>f(v,s)),k=c.map(v=>f(v,s)),F={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:t},I=await this.pathResolver._globWithNormalization(h,F),_=await this.pathResolver._globWithNormalization(m,F),H={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:o.ignore?.filter(v=>v!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(H.ignore)}`);let M=await this.pathResolver._globWithNormalization(S,H),q=await this.pathResolver._globWithNormalization(k,H);this.logger.debug(`Found ${I.length} eager, ${_.length} lazy, ${M.length} framework eager, ${q.length} framework lazy files`),M.length>0?this.logger.debug(`Framework eager files (first 3): ${M.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${p.join(", ")}`),q.length>0?this.logger.debug(`Framework lazy files (first 3): ${q.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${c.join(", ")}`);let re=[...new Set([...I,..._,...M,...q])],Q=new Set([...I,...M]),w={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},{missing:$}=Pe(t),ee=new Set($.filter(v=>v.startsWith("@donotdev/")).map(v=>v.replace("@donotdev/","")));ee.size>0&&this.logger.debug(`I18n namespace filter: excluding [${[...ee].join(", ")}] (packages not installed)`);let j=new Map,K=[...M,...q];for(let v of K){let P=this._processTranslationFile(v,M.includes(v),t);if(P){if(ee.has(P.namespace))continue;let R=`${P.namespace}_${P.language}`;j.set(R,P),w.allNamespaces.add(P.namespace),w.supportedLanguages.add(P.language),M.includes(v)&&w.eagerNamespaces.add(P.namespace)}}let V=new Set;for(let v of re){if(K.includes(v))continue;let P=this._processTranslationFile(v,Q.has(v),t);if(P){let{namespace:R,language:x,importPath:L,content:te}=P,me=`${P.namespace}_${P.language}`;if(j.has(me)){let Ae=j.get(me);P.content=this._mergeTranslations(Ae.content,te)}w.allNamespaces.add(R),w.supportedLanguages.add(x),V.add(x),Q.has(v)&&w.eagerNamespaces.add(R),w.mapping[R]||(w.mapping[R]={}),w.mapping[R][x]=L,P.content&&(w.content[R]||(w.content[R]={}),w.content[R][x]=P.content),w.files.push({path:v,relativePath:this.pathResolver.getRelativePath(v),namespace:R,language:x,eager:Q.has(v),size:P.content?JSON.stringify(P.content).length:0})}}for(let[v,P]of j){let R=v.lastIndexOf("_"),x=v.slice(0,R),L=v.slice(R+1);V.size>0&&!V.has(L)||(!w.mapping[x]||!w.mapping[x][L])&&(w.mapping[x]||(w.mapping[x]={}),w.mapping[x][L]=P.importPath,w.content[x]||(w.content[x]={}),w.content[x][L]=P.content,w.files.push({path:P.absolutePath,relativePath:this.pathResolver.getRelativePath(P.absolutePath),namespace:x,language:L,eager:w.eagerNamespaces.has(x),size:P.content?JSON.stringify(P.content).length:0}))}let O=V.size>0?[...V].sort():[this.options.fallbackLanguage],B=[...new Set(O.map(v=>i.LANGUAGE_FLAG_OVERRIDES[v]||v))];return{mapping:w.mapping,content:w.content,eagerNamespaces:[...w.eagerNamespaces].sort(),allNamespaces:[...w.allNamespaces].sort(),supportedLanguages:O,fallbackLanguage:this.options.fallbackLanguage,flagCodes:B,files:w.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,flagCodes:[i.LANGUAGE_FLAG_OVERRIDES[this.options.fallbackLanguage]||this.options.fallbackLanguage],files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let r=Date.now()-t;return this.logger.debug(`Discovery completed in ${r}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(e=!1){return await this.discover(e)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(e,t,s){let r=e.split("/").pop()||e.split("\\").pop()||"",o,a,n=r.match(/^(.+)_([^_.]+)\.json$/);if(!n)return this.logger.debug(`Invalid translation file name format: ${r}`),null;if([,o,a]=n,!o||!a)return this.logger.debug(`Invalid namespace or language in file: ${r}`),null;let p="./"+this.pathResolver.getRelativePath(e).replace(/\\/g,"/"),c;try{if(c=this.pathResolver.readSync(e,{format:"json"}),!c)return this.logger.debug(`Could not read file: ${e}`),null}catch(u){return this.logger.debug(`Error parsing JSON from ${e}: ${u.message}`),null}return{namespace:o,language:a,importPath:p,absolutePath:e,content:c}}_mergeTranslations(e,t){let s={...e};for(let[r,o]of Object.entries(t))typeof o=="object"&&o!==null&&!Array.isArray(o)?s[r]=this._mergeTranslations(s[r]||{},o):s[r]=o;return s}};var Es=3,pt="dndev-font-preloads.json";function ut({pathResolver:i,debug:e=!1}){let t=C("font-preload-next",e,!1);return{apply(s){s.hooks.afterEmit.tapAsync("DndevFontPreloadManifest",async(r,o)=>{if(r.compiler.isChild()||r.compiler.name?.includes("server"))return o();try{if(!i.getAppRoot())return o();let l=["en"];try{let m=await new ae(i,{fallbackLanguage:"en"}).discoverTranslations();m?.supportedLanguages?.length&&(l=m.supportedLanguages)}catch{}let c=ct(l).stems,u=r.outputOptions.publicPath&&String(r.outputOptions.publicPath)!=="auto"?r.outputOptions.publicPath.replace(/\/$/,""):"",g=[];for(let[d]of Object.entries(r.assets)){if(!d.endsWith(".woff2"))continue;let m=d.toLowerCase();if(Array.from(c).some(S=>m.includes(S))){let S=u?`${u}/${d}`:`/${d}`;if(g.push({href:S,type:"font/woff2"}),g.length>=Es)break}}let f=i.resolveAppPath("public");if(!i.pathExists(f))try{i.ensureDirSync(f)}catch(d){return t.debug(`Font preload: could not create public dir: ${d?.message}`),o()}let h=i.resolvePath(pt,f);i.writeSync(h,JSON.stringify(g,null,0),{overwrite:!0}),t.debug(`Font preload: wrote ${g.length} entries to ${pt}`)}catch(n){t.debug(`Font preload manifest: ${n?.message}`)}o()})}}}import{createRequire as Cs}from"node:module";var gt=Cs(import.meta.url),Oe;function Ns(){return Oe===void 0&&(Oe=[[gt.resolve("@babel/plugin-transform-destructuring"),{loose:!0}],gt.resolve("@babel/plugin-transform-parameters")]),Oe}function ft({logger:i=C("lower-destructuring-next",!1,!1),debug:e=!1}={}){return{apply(t){let{webpack:s}=t,{Compilation:r,sources:o}=s,{RawSource:a}=o;t.hooks.thisCompilation.tap("DndevLowerDestructuring",n=>{n.compiler.isChild()||n.compiler.name?.includes("server")||n.options.mode==="production"&&n.hooks.processAssets.tapPromise({name:"DndevLowerDestructuring",stage:r.PROCESS_ASSETS_STAGE_REPORT},async l=>{let p,c;try{p=(await import("@babel/core")).default,c=Ns()}catch(g){i.warn(`Safari destructuring fix skipped \u2014 Babel not resolvable: ${g?.message}`);return}let u=0;for(let g of Object.keys(l)){if(!g.endsWith(".js"))continue;let f=n.getAsset(g).source.source(),h=typeof f=="string"?f:f.toString("utf8"),d;try{d=p.transformSync(h,{babelrc:!1,configFile:!1,compact:!0,comments:!1,sourceMaps:!1,parserOpts:{sourceType:"unambiguous",allowReturnOutsideFunction:!0},plugins:c})}catch(m){throw new Error(`[lower-destructuring] failed to transform ${g}: ${m.message}`)}d?.code&&d.code!==h&&(n.updateAsset(g,new a(d.code)),u++)}e&&i.debug(`Safari destructuring fix: lowered ${u} client chunks`)})})}}}function ht({postcssImport:i,postcssNesting:e,autoprefixer:t,resolve:s}){return{plugins:[s?i({resolve:s}):i,e,t({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}var dt={"@donotdev/ui/dndev.css":"@donotdev/ui/dndev-next.css"};function Fs(i){return(e,t)=>{dt[e]&&(e=dt[e]);let s=i.resolvePackage(e,t);if(s)return s;if(e.startsWith("@donotdev/")){let r=e.split("/")[0]+"/"+e.split("/")[1],o=e.split("/").slice(2).join("/"),a=i.resolveFrameworkPackage(r,t);if(a){if(o){let l=i.resolvePath(o,a);if(i.pathExists(l))return l;let p=l+".css";if(i.pathExists(p))return p}let n=i.resolvePath("index.css",a);if(i.pathExists(n))return n}}return i.resolvePath(e,t)}}async function Ds(){let[i,e,t]=await Promise.all([import("postcss-import").then(r=>r.default),import("postcss-nesting").then(r=>r.default),import("autoprefixer").then(r=>r.default)]),s=y.getInstance();return ht({postcssImport:i,postcssNesting:e,autoprefixer:t,resolve:Fs(s)})}function Y(i){return i&&typeof i=="object"&&!Array.isArray(i)}var vt={"@donotdev/ui/dndev.css":"@donotdev/ui/dndev-next.css"};function bt({originalWebpack:i,unusedFeaturePackages:e,usedFeaturePackages:t,missingOptionalDeps:s=[],flagCodes:r=[],logger:o,debug:a}){return(n,l)=>{let{dev:p,isServer:c,webpack:u}=l;p&&!c&&(n.infrastructureLogging={level:"error"},n.stats={...n.stats,logging:"error",loggingTrace:!1},n.ignoreWarnings=[...n.ignoreWarnings||[],/WebSocket connection to/,/WebSocket closed without opened/,/failed to connect to websocket/,/WebSocket error/]);let g=n.module?.rules?.find(f=>f.test?.test?.(".svg"));g&&(g.exclude=/\.svg$/i),n.module=n.module||{},n.module.rules=n.module.rules||[],n.module.rules.push({test:/\.svg$/i,type:"asset/resource",generator:{filename:"static/media/[name].[hash][ext]"}}),n.module.rules.push({test:/\.md$/,type:"asset/source"}),n.resolve=n.resolve||{},n.resolve.alias=n.resolve.alias||{};try{let f=y.getInstance(),h=f.resolveAppPath(D.next.blogContent);n.resolve.alias[Ee.blog]=mt.existsSync(h)?h:f.getEmptyCjsModulePath()}catch(f){o.debug(`Blog content alias fallback to empty stub: ${f?.message}`)}n.resolve=n.resolve||{},n.resolve.alias={...n.resolve.alias,...vt},u?.IgnorePlugin&&n.plugins.push(new u.IgnorePlugin({resourceRegExp:/^(vite|@vitejs|vite-tsconfig-paths)$/}));try{let f=y.getInstance();n.plugins.push(ut({pathResolver:f,debug:a}))}catch(f){o.debug(`Font preload webpack plugin skipped: ${f?.message}`)}if(!c)try{n.plugins.push(ft({logger:o,debug:a}))}catch(f){o.debug(`Lower-destructuring webpack plugin skipped: ${f?.message}`)}if(e.length>0)if(o.info(`\u{1F6AB} Excluding unused features: ${e.join(", ")}`),o.info(`\u2705 Including features: ${t.join(", ")}`),n.externals=n.externals||[],Array.isArray(n.externals))n.externals.push(...e);else{let f=n.externals;n.externals=(h,d,m)=>e.includes(d)?m(null,"commonjs "+d):typeof f=="function"?f(h,d,m):m()}if(s.length>0&&u?.NormalModuleReplacementPlugin){let h=y.getInstance().getEmptyCjsModulePath(),d=s.map(S=>S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),m=new RegExp(`^(${d.join("|")})(\\/|$)`);n.plugins.push(new u.NormalModuleReplacementPlugin(m,h)),a&&o.debug(`Aliased ${s.length} missing optional deps to empty module`)}if(r.length>0&&u?.NormalModuleReplacementPlugin){let h=y.getInstance().getEmptyFlagModulePath(),d=new Set(r.map(m=>m.toUpperCase()));n.plugins.push(new u.NormalModuleReplacementPlugin(/flags\/raw\/flag([A-Z][A-Z0-9_-]*)\./,m=>{let S=m.request.match(/flag([A-Z][A-Z0-9_-]*)\./i);S&&S[1].toUpperCase()!=="BASE"&&!d.has(S[1].toUpperCase())&&(m.request=h)})),a&&o.debug(`Flag filter: allowing ${d.size} flags, aliasing rest to empty component`)}return i?i(n,l):n}}function yt({originalRewrites:i,handlers:e,logger:t}){return async function(){try{let s=i?await i():[],o=e.filter(n=>n?.getAPIRewrites).map(n=>n.getAPIRewrites()).reduce((n,l)=>(l?.beforeFiles&&n.beforeFiles.push(...l.beforeFiles),l?.afterFiles&&n.afterFiles.push(...l.afterFiles),l?.fallback&&n.fallback.push(...l.fallback),n),{beforeFiles:[],afterFiles:[],fallback:[]});return{beforeFiles:[...Array.isArray(s)?[]:s?.beforeFiles||[],...o.beforeFiles],afterFiles:[...Array.isArray(s)?s:s?.afterFiles||[],...o.afterFiles],fallback:[...Array.isArray(s)?[]:s?.fallback||[],...o.fallback]}}catch(s){return t.error(`Next.js config failed to merge rewrites: ${s.message}`),t.error(`Stack: ${s.stack||"No stack trace available"}`),{beforeFiles:[],afterFiles:[],fallback:[]}}}}function wt({originalRedirects:i,seoRedirects:e,logger:t}){return async function(){try{let s=i?await i():[],r=(e||[]).map(({from:l,to:p,permanent:c})=>({source:l,destination:p,permanent:c!==!1})),o=[],a=new Set;for(let l of r){let p=l.source.replace(/\/+$/,"")||"/",c=l.destination.replace(/\/+$/,"")||"/";if(p===c){t.warn(`Redirect loop detected: ${l.source} \u2192 ${l.destination} (skipped)`);continue}if(!l.source.startsWith("/")){t.warn(`Redirect source must start with /: "${l.source}" (skipped)`);continue}if(a.has(p)){t.warn(`Duplicate redirect source: "${l.source}" (skipped)`);continue}a.add(p),o.push(l)}let n=[...Array.isArray(s)?s:[],...o];return n.length===0?[]:(t.info(` \u{1F4CE} ${n.length} redirect${n.length>1?"s":""} configured`),n)}catch(s){return t.error(`Failed to merge redirects: ${s.message}`),[]}}}function Pt({routeResult:i,themeResult:e,i18nResult:t,assetResult:s,seoResult:r,pwaResult:o,serverShimResult:a,restNextConfig:n,discoveredPackages:l,webpackConfig:p,rewritesConfig:c,redirectsConfig:u,missingOptionalDeps:g,flagCodes:f=[],pathResolver:h,env:d,logger:m}){let S=n?.output==="export",F=n?.distDir||".next";return{transpilePackages:[...l,...g||[]],...Y(n)?n:(m.warn("restNextConfig is not a plain object:",n),{}),serverExternalPackages:(n?.serverExternalPackages||n?.serverComponentsExternalPackages||[]).filter(_=>!_.startsWith("@donotdev/")&&!g?.includes(_)),turbopack:{...n?.turbopack||{},root:n?.turbopack?.root||h.getRepoRoot(),resolveAlias:{...n?.turbopack?.resolveAlias||{},...vt,[Ee.blog]:(()=>{try{let _=h.resolveAppPath(D.next.blogContent);if(mt.existsSync(_))return"./"+D.next.blogContent}catch{}return"@donotdev/core/empty"})(),...g?.length>0?Object.fromEntries(g.flatMap(_=>[[_,"@donotdev/core/empty"],[`${_}/*`,"@donotdev/core/empty"]])):{}}},distDir:F,...process.env.NODE_ENV==="development"&&{devIndicators:{position:"bottom-right"},onDemandEntries:{maxInactiveAge:60*1e3,pagesBufferLength:5}},...Y(i)?i:(m.error(`Route handler config invalid (got ${typeof i}):`,i),{}),...Y(e)?e:(m.error(`Theme handler config invalid (got ${typeof e}):`,e),{}),...Y(t)?t:(m.error(`I18n handler config invalid (got ${typeof t}):`,t),{}),...Y(s)?s:(m.error(`Asset handler config invalid (got ${typeof s}):`,s),{}),...Y(r)?r:(m.error(`SEO handler config invalid (got ${typeof r}):`,r),{}),...Y(o)?o:(m.error(`PWA handler config invalid (got ${typeof o}):`,o),{}),...Y(a)?a:(m.warn("serverShimConfig returned non-object:",a),{}),webpack:p,...S?{}:{rewrites:c,...u?{redirects:u}:{}},env:d,...process.env.NODE_ENV==="production"&&{logging:{fetches:{fullUrl:!1}}}}}var Se="fonts",Te="dndev-fonts.css",Os=/@import\s+['"]@fontsource\/([^/]+)\/(\d+)\.css['"]/g,$t=/url\(\.\/files\/([^)]+)\)/g;function Ts(i){let e=new Set(["latin"]);for(let t of i){let s=ye[t];if(s)for(let r of s)e.add(r)}return e}function Is(i,e){let t=i.resolvePath("src/dndev.css",e),s=i.readSync(t,{format:"text"});if(!s)return[];let r=[],o;for(;(o=Os.exec(s))!==null;)r.push([o[1],o[2]]);return r}function Ms(i,e,t,s,r){let o=[`/* Auto-generated by @donotdev/core \u2014 do not edit */
|
|
4
|
-
`],a=new Set,n=r&&r.size>0;for(let[l,p]of e){let c=i.resolveFrameworkPackage(`@fontsource/${l}`);if(!c){s.debug(`@fontsource/${l} not found`);continue}let u=!!oe[l];if(n&&u)for(let g of r){let f=i.resolvePath(`${g}-${p}.css`,c),h=i.readSync(f,{format:"text"});if(!h)continue;let d
|
|
5
|
-
`,...n.map(h=>{let d=l&&Array.from(p).some(
|
|
6
|
-
`)),s.debug(`Font copy: wrote ${Te} (${u.size} font files copied)`)}function Rt(){let i=y.getInstance(),e=i.resolveAppPath(`public/${Te}`),t=i.resolveAppPath(`public/${
|
|
3
|
+
`;a.appendFile(n,d)}},p=(c,u)=>{if(u.length===0)return c;let g=u.map(f=>typeof f=="object"?JSON.stringify(f,null,2):String(f)).join(" ");return`${c} ${g}`};return{debug:(c,...u)=>{e&&(o?l("DEBUG",c,u):T.log.message(J(p(c,u),W.gray)))},verbose:(c,...u)=>{t&&(o?l("VERBOSE",c,u):T.log.message(p(c,u)))},info:(c,...u)=>{o?l("INFO",c,u):T.log.info(J(p(c,u),W.brightCyan))},warn:(c,...u)=>{e&&o?l("WARN",c,u):T.log.warn(J(p(c,u),W.brightYellow))},error:(c,...u)=>{e&&o?l("ERROR",c,u):T.log.error(J(p(c,u),W.brightRed))},success:(c,...u)=>{e&&o?l("SUCCESS",c,u):T.log.success(J(p(c,u),W.brightGreen))},when:(c,u="debug")=>(g,...f)=>{if(c){let h=p(g,f);switch(u){case"verbose":t&&(T.log.message(h),l("VERBOSE",g,f));break;case"info":T.log.info(J(h,W.brightCyan)),l("INFO",g,f);break;case"warn":T.log.warn(J(h,W.brightYellow)),l("WARN",g,f);break;case"error":T.log.error(J(h,W.brightRed)),l("ERROR",g,f);break;case"success":T.log.success(J(h,W.brightGreen)),l("SUCCESS",g,f);break;default:e&&(T.log.message(J(h,W.gray)),l("DEBUG",g,f))}}},getLogFilePath:()=>n}}var G=class i{constructor(e,t={}){if(this.constructor===i)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...t},process.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=C(this._getDiscoveryType(),this.options.debug,this.options.verbose,{fileLogging:this.options.fileLogging,logDir:this.options.logDir}),this.cache=null,this._lastDiscoveryTime=0}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._getPatterns();this.options.verbose&&s&&(typeof s=="object"&&s.pattern?this.logger.verbose(`Pattern: ${s.pattern}`):typeof s=="string"&&this.logger.verbose(`Pattern: ${s}`),s.dirs&&this.logger.verbose(`Search directories: ${s.dirs.slice(0,3).join(", ")}${s.dirs.length>3?` (${s.dirs.length} total)`:""}`));let r=await this._scanFiles(s),o=await this._processFiles(r);this.cache={...o,timestamp:Date.now()};let a=Date.now()-t;return this.logger.debug(`Discovery completed in ${a}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){return this.logger.error(`${this._getDiscoveryType()} discovery failed during file scanning: ${s.message}`),this.logger.error(`Stack: ${s.stack||"No stack trace available"}`),this._getEmptyResult()}}clearCache(){this.cache=null,this._lastDiscoveryTime=0,this.logger.debug("Cache cleared")}getCachedResults(){return this.cache}_getDiscoveryType(){throw new Error("_getDiscoveryType must be implemented by subclass")}_getPatterns(){throw new Error("_getPatterns must be implemented by subclass")}_getPatternType(){throw new Error("_getPatternType must be implemented by subclass")}async _processFiles(e){throw new Error("_processFiles must be implemented by subclass")}_getEmptyResult(){throw new Error("_getEmptyResult must be implemented by subclass")}_getDiscoverySummary(){throw new Error("_getDiscoverySummary must be implemented by subclass")}async _scanFiles(e){let t=this._getPatternType();return await this.pathResolver.resolveFiles(e,t)}_extractFileNameInfo(e){let t=e.split("/"),s=t[t.length-1],r=s.split(".")[0],o=s.split(".").pop();return{fileName:s,baseName:r,extension:o,directory:t.slice(0,-1).join("/")}}async _processSingleFile(e,t){try{let s=this.pathResolver.getFileInfo(e);return s?await t(s):(this.logger.debug(`Could not get file info: ${e}`),null)}catch(s){return this.logger.debug(`Error processing file ${e}: ${s.message}`),null}}async _batchProcessFiles(e,t){return(await Promise.all(e.map(r=>this._processSingleFile(r,t)))).filter(r=>r!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};function xs(i){if(!i)return[];let e=y.getInstance(),t=new Set;try{let s=e.resolvePackage("@donotdev/core",i);if(!s)return[];let r=e.getDirname(e.getDirname(s)),o;try{o=e.readdirSync(r)}catch{return[]}for(let a of o)try{let n=e.resolvePath(`${a}/package.json`,r),l=e.readSync(n,{format:"json"});if(!l?.peerDependenciesMeta)continue;for(let[p,c]of Object.entries(l.peerDependenciesMeta))c?.optional&&t.add(p)}catch{}}catch{}return Array.from(t)}function Rs(i){if(!i)return[];let e=y.getInstance();try{let t=e.resolvePath("package.json",i),s=e.readSync(t,{format:"json"});if(!s)return[];let r=new Set;if(s.peerDependenciesMeta)for(let[o,a]of Object.entries(s.peerDependenciesMeta))a?.optional&&r.add(o);if(s.optionalDependencies)for(let o of Object.keys(s.optionalDependencies))r.add(o);return Array.from(r)}catch{return[]}}function ks(i){let e=be.optionalFeatures||[],t=xs(i),s=Rs(i);return[...new Set([...e,...t,...s])]}function _s(i){let e=y.getInstance();try{let t=e.resolvePath("package.json",i),s=e.readSync(t,{format:"json"});return s?new Set([...Object.keys(s.dependencies||{}),...Object.keys(s.devDependencies||{})]):new Set}catch{return new Set}}function As(i,e,t){if(t.resolvePackage(i,e||void 0))return!0;let s=i.startsWith("@")?i.split("/").slice(0,2).join("/"):i.split("/")[0],r=e;for(let o=0;o<10;o++){let a=t.resolvePath(`node_modules/${s}`,r);if(t.pathExists(a))return!0;let n=t.getDirname(r);if(n===r)break;r=n}return!1}function Pe(i){let e=ks(i),t=[],s=[],r=y.getInstance(),o=_s(i);for(let a of e)a.startsWith("@donotdev/")?o.has(a)?s.push(a):t.push(a):o.has(a)&&As(a,i,r)?s.push(a):t.push(a);return{missing:t,installed:s}}var ae=class i extends G{static LANGUAGE_FLAG_OVERRIDES={en:"gb","en-ca":"ca","es-ar":"ar","fr-be":"be",ar:"sa","ar-ma":"ma","ar-dz":"dz","ar-tn":"tn","ar-ly":"ly","ar-mr":"mr",hi:"in",sl:"si",uk:"ua",ga:"ie",gd:"gb-sct",br:"bzh",co:"fr-cor",am:"et",bn:"bd",gu:"in",kn:"in",ml:"in",mr:"in",ne:"np",pa:"pk",ta:"in",te:"in",ur:"pk",fa:"ir",kk:"kz",ky:"kg",tg:"tj",my:"mm",km:"kh",lo:"la",ka:"ge",hy:"am",be:"by",bs:"ba",sq:"al",ms:"my"};constructor(e,t={}){super(e,{fallbackLanguage:"en",additionalPaths:[],...t})}_getDiscoveryType(){return"I18n"}async _getPatterns(){return await this.pathResolver.resolvePatterns("i18n")}_getPatternType(){return"i18n"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=this.pathResolver.getRepoRoot();if(!t||t===s)throw this.logger.error(`I18n discovery: appRoot not properly set (appRoot: ${t}, repoRoot: ${s})`),new Error("App root not set before i18n discovery. Ensure configResolved hook has run.");this.logger.debug(`I18n discovery: appRoot=${t}, repoRoot=${s}`);let r=await this._getPatterns();this.logger.debug(`I18n patterns - eager: ${r.eager.length}, lazy: ${r.lazy.length}, framework eager: ${r.framework?.eager?.length||0}, framework lazy: ${r.framework?.lazy?.length||0}`),this.logger.debug(`isMonorepo: ${this.pathResolver.isMonorepo()}, repoRoot: ${this.pathResolver.getRepoRoot()}`);let o=we("i18n"),a=r.eager||[],n=r.lazy||[],l=(this.options.additionalPaths||[]).map(v=>{let P=v.endsWith(".json")?v:`${v}/*_*.json`;return this.pathResolver.resolveAppPath(P)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let p=r.framework?.eager||[],c=r.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${a.join(", ")}, lazy: ${n.join(", ")}, framework eager: ${p.join(", ")}, framework lazy: ${c.join(", ")}`),p.length===0&&c.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let u=this.pathResolver.normalizePath(t),g=this.pathResolver.normalizePath(s),f=(v,P)=>{let R=this.pathResolver.normalizePath(v),x=this.pathResolver.normalizePath(P);return R.startsWith(x)?R.slice(x.length+1):R},h=a.map(v=>f(v,t)),m=[...n,...l].map(v=>f(v,t)),$=p.map(v=>f(v,s)),k=c.map(v=>f(v,s)),F={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:t},I=await this.pathResolver._globWithNormalization(h,F),_=await this.pathResolver._globWithNormalization(m,F),H={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:o.ignore?.filter(v=>v!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(H.ignore)}`);let M=await this.pathResolver._globWithNormalization($,H),q=await this.pathResolver._globWithNormalization(k,H);this.logger.debug(`Found ${I.length} eager, ${_.length} lazy, ${M.length} framework eager, ${q.length} framework lazy files`),M.length>0?this.logger.debug(`Framework eager files (first 3): ${M.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${p.join(", ")}`),q.length>0?this.logger.debug(`Framework lazy files (first 3): ${q.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${c.join(", ")}`);let re=[...new Set([...I,..._,...M,...q])],Q=new Set([...I,...M]),w={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},{missing:S}=Pe(t),ee=new Set(S.filter(v=>v.startsWith("@donotdev/")).map(v=>v.replace("@donotdev/","")));ee.size>0&&this.logger.debug(`I18n namespace filter: excluding [${[...ee].join(", ")}] (packages not installed)`);let j=new Map,K=[...M,...q];for(let v of K){let P=this._processTranslationFile(v,M.includes(v),t);if(P){if(ee.has(P.namespace))continue;let R=`${P.namespace}_${P.language}`;j.set(R,P),w.allNamespaces.add(P.namespace),w.supportedLanguages.add(P.language),M.includes(v)&&w.eagerNamespaces.add(P.namespace)}}let V=new Set;for(let v of re){if(K.includes(v))continue;let P=this._processTranslationFile(v,Q.has(v),t);if(P){let{namespace:R,language:x,importPath:L,content:te}=P,me=`${P.namespace}_${P.language}`;if(j.has(me)){let Ae=j.get(me);P.content=this._mergeTranslations(Ae.content,te)}w.allNamespaces.add(R),w.supportedLanguages.add(x),V.add(x),Q.has(v)&&w.eagerNamespaces.add(R),w.mapping[R]||(w.mapping[R]={}),w.mapping[R][x]=L,P.content&&(w.content[R]||(w.content[R]={}),w.content[R][x]=P.content),w.files.push({path:v,relativePath:this.pathResolver.getRelativePath(v),namespace:R,language:x,eager:Q.has(v),size:P.content?JSON.stringify(P.content).length:0})}}for(let[v,P]of j){let R=v.lastIndexOf("_"),x=v.slice(0,R),L=v.slice(R+1);V.size>0&&!V.has(L)||(!w.mapping[x]||!w.mapping[x][L])&&(w.mapping[x]||(w.mapping[x]={}),w.mapping[x][L]=P.importPath,w.content[x]||(w.content[x]={}),w.content[x][L]=P.content,w.files.push({path:P.absolutePath,relativePath:this.pathResolver.getRelativePath(P.absolutePath),namespace:x,language:L,eager:w.eagerNamespaces.has(x),size:P.content?JSON.stringify(P.content).length:0}))}let O=V.size>0?[...V].sort():[this.options.fallbackLanguage],B=[...new Set(O.map(v=>i.LANGUAGE_FLAG_OVERRIDES[v]||v))];return{mapping:w.mapping,content:w.content,eagerNamespaces:[...w.eagerNamespaces].sort(),allNamespaces:[...w.allNamespaces].sort(),supportedLanguages:O,fallbackLanguage:this.options.fallbackLanguage,flagCodes:B,files:w.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],fallbackLanguage:this.options.fallbackLanguage,flagCodes:[i.LANGUAGE_FLAG_OVERRIDES[this.options.fallbackLanguage]||this.options.fallbackLanguage],files:[],timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.allNamespaces?.length||0} namespaces, ${this.cache?.supportedLanguages?.length||0} languages`}async discover(e=!1){if(!e&&this._isCacheValid())return this.logger.debug("Using cached results"),this.cache;let t=Date.now();try{let s=await this._processFiles([]);this.cache={...s,timestamp:Date.now()};let r=Date.now()-t;return this.logger.debug(`Discovery completed in ${r}ms`),this._lastDiscoveryTime=Date.now(),this.cache}catch(s){throw this.logger.error(`I18n discovery failed: ${s.message}`),s}}async discoverTranslations(e=!1){return await this.discover(e)}getMapping(){return this.cache?.mapping||{}}getLanguages(){return this.cache?.supportedLanguages||[this.options.fallbackLanguage]}getNamespaces(){return this.cache?.allNamespaces||["common"]}getEagerNamespaces(){return this.cache?.eagerNamespaces||[]}_processTranslationFile(e,t,s){let r=e.split("/").pop()||e.split("\\").pop()||"",o,a,n=r.match(/^(.+)_([^_.]+)\.json$/);if(!n)return this.logger.debug(`Invalid translation file name format: ${r}`),null;if([,o,a]=n,!o||!a)return this.logger.debug(`Invalid namespace or language in file: ${r}`),null;let p="./"+this.pathResolver.getRelativePath(e).replace(/\\/g,"/"),c;try{if(c=this.pathResolver.readSync(e,{format:"json"}),!c)return this.logger.debug(`Could not read file: ${e}`),null}catch(u){return this.logger.debug(`Error parsing JSON from ${e}: ${u.message}`),null}return{namespace:o,language:a,importPath:p,absolutePath:e,content:c}}_mergeTranslations(e,t){let s={...e};for(let[r,o]of Object.entries(t))typeof o=="object"&&o!==null&&!Array.isArray(o)?s[r]=this._mergeTranslations(s[r]||{},o):s[r]=o;return s}};var Es=3,pt="dndev-font-preloads.json";function ut({pathResolver:i,debug:e=!1}){let t=C("font-preload-next",e,!1);return{apply(s){s.hooks.afterEmit.tapAsync("DndevFontPreloadManifest",async(r,o)=>{if(r.compiler.isChild()||r.compiler.name?.includes("server"))return o();try{if(!i.getAppRoot())return o();let l=["en"];try{let m=await new ae(i,{fallbackLanguage:"en"}).discoverTranslations();m?.supportedLanguages?.length&&(l=m.supportedLanguages)}catch{}let c=ct(l).stems,u=r.outputOptions.publicPath&&String(r.outputOptions.publicPath)!=="auto"?r.outputOptions.publicPath.replace(/\/$/,""):"",g=[];for(let[d]of Object.entries(r.assets)){if(!d.endsWith(".woff2"))continue;let m=d.toLowerCase();if(Array.from(c).some($=>m.includes($))){let $=u?`${u}/${d}`:`/${d}`;if(g.push({href:$,type:"font/woff2"}),g.length>=Es)break}}let f=i.resolveAppPath("public");if(!i.pathExists(f))try{i.ensureDirSync(f)}catch(d){return t.debug(`Font preload: could not create public dir: ${d?.message}`),o()}let h=i.resolvePath(pt,f);i.writeSync(h,JSON.stringify(g,null,0),{overwrite:!0}),t.debug(`Font preload: wrote ${g.length} entries to ${pt}`)}catch(n){t.debug(`Font preload manifest: ${n?.message}`)}o()})}}}import{createRequire as Cs}from"node:module";var gt=Cs(import.meta.url),Oe;function Ns(){return Oe===void 0&&(Oe=[[gt.resolve("@babel/plugin-transform-destructuring"),{loose:!0}],gt.resolve("@babel/plugin-transform-parameters")]),Oe}function ft({logger:i=C("lower-destructuring-next",!1,!1),debug:e=!1}={}){return{apply(t){let{webpack:s}=t,{Compilation:r,sources:o}=s,{RawSource:a}=o;t.hooks.thisCompilation.tap("DndevLowerDestructuring",n=>{n.compiler.isChild()||n.compiler.name?.includes("server")||n.options.mode==="production"&&n.hooks.processAssets.tapPromise({name:"DndevLowerDestructuring",stage:r.PROCESS_ASSETS_STAGE_REPORT},async l=>{let p,c;try{p=(await import("@babel/core")).default,c=Ns()}catch(g){i.warn(`Safari destructuring fix skipped \u2014 Babel not resolvable: ${g?.message}`);return}let u=0;for(let g of Object.keys(l)){if(!g.endsWith(".js"))continue;let f=n.getAsset(g).source.source(),h=typeof f=="string"?f:f.toString("utf8"),d;try{d=p.transformSync(h,{babelrc:!1,configFile:!1,compact:!0,comments:!1,sourceMaps:!1,parserOpts:{sourceType:"unambiguous",allowReturnOutsideFunction:!0},plugins:c})}catch(m){throw new Error(`[lower-destructuring] failed to transform ${g}: ${m.message}`)}d?.code&&d.code!==h&&(n.updateAsset(g,new a(d.code)),u++)}e&&i.debug(`Safari destructuring fix: lowered ${u} client chunks`)})})}}}function ht({postcssImport:i,postcssNesting:e,autoprefixer:t,resolve:s}){return{plugins:[s?i({resolve:s}):i,e,t({overrideBrowserslist:["> 1%","last 2 versions","Firefox ESR","not dead","not op_mini all"],grid:"autoplace"})]}}var dt={"@donotdev/ui/dndev.css":"@donotdev/ui/dndev-next.css"};function Fs(i){return(e,t)=>{dt[e]&&(e=dt[e]);let s=i.resolvePackage(e,t);if(s)return s;if(e.startsWith("@donotdev/")){let r=e.split("/")[0]+"/"+e.split("/")[1],o=e.split("/").slice(2).join("/"),a=i.resolveFrameworkPackage(r,t);if(a){if(o){let l=i.resolvePath(o,a);if(i.pathExists(l))return l;let p=l+".css";if(i.pathExists(p))return p}let n=i.resolvePath("index.css",a);if(i.pathExists(n))return n}}return i.resolvePath(e,t)}}async function Ds(){let[i,e,t]=await Promise.all([import("postcss-import").then(r=>r.default),import("postcss-nesting").then(r=>r.default),import("autoprefixer").then(r=>r.default)]),s=y.getInstance();return ht({postcssImport:i,postcssNesting:e,autoprefixer:t,resolve:Fs(s)})}function Y(i){return i&&typeof i=="object"&&!Array.isArray(i)}var vt={"@donotdev/ui/dndev.css":"@donotdev/ui/dndev-next.css"};function bt({originalWebpack:i,unusedFeaturePackages:e,usedFeaturePackages:t,missingOptionalDeps:s=[],flagCodes:r=[],logger:o,debug:a}){return(n,l)=>{let{dev:p,isServer:c,webpack:u}=l;p&&!c&&(n.infrastructureLogging={level:"error"},n.stats={...n.stats,logging:"error",loggingTrace:!1},n.ignoreWarnings=[...n.ignoreWarnings||[],/WebSocket connection to/,/WebSocket closed without opened/,/failed to connect to websocket/,/WebSocket error/]);let g=n.module?.rules?.find(f=>f.test?.test?.(".svg"));g&&(g.exclude=/\.svg$/i),n.module=n.module||{},n.module.rules=n.module.rules||[],n.module.rules.push({test:/\.svg$/i,type:"asset/resource",generator:{filename:"static/media/[name].[hash][ext]"}}),n.module.rules.push({test:/\.md$/,type:"asset/source"}),n.resolve=n.resolve||{},n.resolve.alias=n.resolve.alias||{};try{let f=y.getInstance(),h=f.resolveAppPath(D.next.blogContent);n.resolve.alias[Ee.blog]=mt.existsSync(h)?h:f.getEmptyCjsModulePath()}catch(f){o.debug(`Blog content alias fallback to empty stub: ${f?.message}`)}n.resolve=n.resolve||{},n.resolve.alias={...n.resolve.alias,...vt},u?.IgnorePlugin&&n.plugins.push(new u.IgnorePlugin({resourceRegExp:/^(vite|@vitejs|vite-tsconfig-paths)$/}));try{let f=y.getInstance();n.plugins.push(ut({pathResolver:f,debug:a}))}catch(f){o.debug(`Font preload webpack plugin skipped: ${f?.message}`)}if(!c)try{n.plugins.push(ft({logger:o,debug:a}))}catch(f){o.debug(`Lower-destructuring webpack plugin skipped: ${f?.message}`)}if(e.length>0)if(o.info(`\u{1F6AB} Excluding unused features: ${e.join(", ")}`),o.info(`\u2705 Including features: ${t.join(", ")}`),n.externals=n.externals||[],Array.isArray(n.externals))n.externals.push(...e);else{let f=n.externals;n.externals=(h,d,m)=>e.includes(d)?m(null,"commonjs "+d):typeof f=="function"?f(h,d,m):m()}if(s.length>0&&u?.NormalModuleReplacementPlugin){let h=y.getInstance().getEmptyCjsModulePath(),d=s.map($=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),m=new RegExp(`^(${d.join("|")})(\\/|$)`);n.plugins.push(new u.NormalModuleReplacementPlugin(m,h)),a&&o.debug(`Aliased ${s.length} missing optional deps to empty module`)}if(r.length>0&&u?.NormalModuleReplacementPlugin){let h=y.getInstance().getEmptyFlagModulePath(),d=new Set(r.map(m=>m.toUpperCase()));n.plugins.push(new u.NormalModuleReplacementPlugin(/flags\/raw\/flag([A-Z][A-Z0-9_-]*)\./,m=>{let $=m.request.match(/flag([A-Z][A-Z0-9_-]*)\./i);$&&$[1].toUpperCase()!=="BASE"&&!d.has($[1].toUpperCase())&&(m.request=h)})),a&&o.debug(`Flag filter: allowing ${d.size} flags, aliasing rest to empty component`)}return i?i(n,l):n}}function yt({originalRewrites:i,handlers:e,logger:t}){return async function(){try{let s=i?await i():[],o=e.filter(n=>n?.getAPIRewrites).map(n=>n.getAPIRewrites()).reduce((n,l)=>(l?.beforeFiles&&n.beforeFiles.push(...l.beforeFiles),l?.afterFiles&&n.afterFiles.push(...l.afterFiles),l?.fallback&&n.fallback.push(...l.fallback),n),{beforeFiles:[],afterFiles:[],fallback:[]});return{beforeFiles:[...Array.isArray(s)?[]:s?.beforeFiles||[],...o.beforeFiles],afterFiles:[...Array.isArray(s)?s:s?.afterFiles||[],...o.afterFiles],fallback:[...Array.isArray(s)?[]:s?.fallback||[],...o.fallback]}}catch(s){return t.error(`Next.js config failed to merge rewrites: ${s.message}`),t.error(`Stack: ${s.stack||"No stack trace available"}`),{beforeFiles:[],afterFiles:[],fallback:[]}}}}function wt({originalRedirects:i,seoRedirects:e,logger:t}){return async function(){try{let s=i?await i():[],r=(e||[]).map(({from:l,to:p,permanent:c})=>({source:l,destination:p,permanent:c!==!1})),o=[],a=new Set;for(let l of r){let p=l.source.replace(/\/+$/,"")||"/",c=l.destination.replace(/\/+$/,"")||"/";if(p===c){t.warn(`Redirect loop detected: ${l.source} \u2192 ${l.destination} (skipped)`);continue}if(!l.source.startsWith("/")){t.warn(`Redirect source must start with /: "${l.source}" (skipped)`);continue}if(a.has(p)){t.warn(`Duplicate redirect source: "${l.source}" (skipped)`);continue}a.add(p),o.push(l)}let n=[...Array.isArray(s)?s:[],...o];return n.length===0?[]:(t.info(` \u{1F4CE} ${n.length} redirect${n.length>1?"s":""} configured`),n)}catch(s){return t.error(`Failed to merge redirects: ${s.message}`),[]}}}function Pt({routeResult:i,themeResult:e,i18nResult:t,assetResult:s,seoResult:r,pwaResult:o,serverShimResult:a,restNextConfig:n,discoveredPackages:l,webpackConfig:p,rewritesConfig:c,redirectsConfig:u,missingOptionalDeps:g,flagCodes:f=[],pathResolver:h,env:d,logger:m}){let $=n?.output==="export",F=n?.distDir||".next";return{transpilePackages:[...l,...g||[]],...Y(n)?n:(m.warn("restNextConfig is not a plain object:",n),{}),serverExternalPackages:(n?.serverExternalPackages||n?.serverComponentsExternalPackages||[]).filter(_=>!_.startsWith("@donotdev/")&&!g?.includes(_)),turbopack:{...n?.turbopack||{},root:n?.turbopack?.root||h.getRepoRoot(),resolveAlias:{...n?.turbopack?.resolveAlias||{},...vt,[Ee.blog]:(()=>{try{let _=h.resolveAppPath(D.next.blogContent);if(mt.existsSync(_))return"./"+D.next.blogContent}catch{}return"@donotdev/core/empty"})(),...g?.length>0?Object.fromEntries(g.flatMap(_=>[[_,"@donotdev/core/empty"],[`${_}/*`,"@donotdev/core/empty"]])):{}}},distDir:F,...process.env.NODE_ENV==="development"&&{devIndicators:{position:"bottom-right"},onDemandEntries:{maxInactiveAge:60*1e3,pagesBufferLength:5}},...Y(i)?i:(m.error(`Route handler config invalid (got ${typeof i}):`,i),{}),...Y(e)?e:(m.error(`Theme handler config invalid (got ${typeof e}):`,e),{}),...Y(t)?t:(m.error(`I18n handler config invalid (got ${typeof t}):`,t),{}),...Y(s)?s:(m.error(`Asset handler config invalid (got ${typeof s}):`,s),{}),...Y(r)?r:(m.error(`SEO handler config invalid (got ${typeof r}):`,r),{}),...Y(o)?o:(m.error(`PWA handler config invalid (got ${typeof o}):`,o),{}),...Y(a)?a:(m.warn("serverShimConfig returned non-object:",a),{}),webpack:p,...$?{}:{rewrites:c,...u?{redirects:u}:{}},env:d,...process.env.NODE_ENV==="production"&&{logging:{fetches:{fullUrl:!1}}}}}var $e="fonts",Te="dndev-fonts.css",Os=/@import\s+['"]@fontsource\/([^/]+)\/(\d+)\.css['"]/g,St=/url\(\.\/files\/([^)]+)\)/g;function Ts(i){let e=new Set(["latin"]);for(let t of i){let s=ye[t];if(s)for(let r of s)e.add(r)}return e}function Is(i,e){let t=i.resolvePath("src/dndev.css",e),s=i.readSync(t,{format:"text"});if(!s)return[];let r=[],o;for(;(o=Os.exec(s))!==null;)r.push([o[1],o[2]]);return r}function Ms(i,e,t,s,r){let o=[`/* Auto-generated by @donotdev/core \u2014 do not edit */
|
|
4
|
+
`],a=new Set,n=r&&r.size>0;for(let[l,p]of e){let c=i.resolveFrameworkPackage(`@fontsource/${l}`);if(!c){s.debug(`@fontsource/${l} not found`);continue}let u=!!oe[l];if(n&&u)for(let g of r){let f=i.resolvePath(`${g}-${p}.css`,c),h=i.readSync(f,{format:"text"});if(!h)continue;let d=$t(De(h),i,c,t,a,s,!0);o.push(d)}else{let g=i.resolvePath(`${p}.css`,c),f=i.readSync(g,{format:"text"});if(!f){s.debug(`Missing: @fontsource/${l}/${p}.css`);continue}let h=$t(f,i,c,t,a,s,!1);o.push(h)}}return{cssChunks:o,copiedFiles:a}}function $t(i,e,t,s,r,o,a){return i.replace(St,(n,l)=>{if(a&&l.endsWith(".woff"))return"url(data:,)";let p=e.resolvePath(`files/${l}`,t);if(!e.pathExists(p))return o.warn(`Font file missing: ${p} \u2014 dropping from CSS`),"url(data:,)";if(!r.has(l)){let u=e.resolvePath(l,s);e.copySync(p,u,{overwrite:!0}),r.add(l)}return`url(/${$e}/${l})`})}var js=/@font-face\s*\{[^}]*\}/g;function Ls(i,e,t,s,r){let o=i.resolvePath("dist/dndev.css",e),a=i.readSync(o,{format:"text"});if(!a)return s.debug("dist/dndev.css not found in @donotdev/ui"),{cssChunks:[],copiedFiles:new Set};let n=a.match(js);if(!n||n.length===0)return s.debug("No @font-face blocks found in dist/dndev.css"),{cssChunks:[],copiedFiles:new Set};let l=r&&r.size>0,p=new Set(Object.keys(oe));l&&(n=n.filter(h=>{if(!Array.from(p).some(m=>h.includes(`${m}-`)))return!0;for(let m of r)if(h.includes(`-${m}-`))return!0;return!1}));let c=i.resolvePath("dist/files",e),u=new Set;return{cssChunks:[`/* Auto-generated by @donotdev/core \u2014 do not edit */
|
|
5
|
+
`,...n.map(h=>{let d=l&&Array.from(p).some($=>h.includes(`${$}-`));return(d?De(h):h).replace(St,($,k)=>{if(d&&k.endsWith(".woff"))return"url(data:,)";let F=i.resolvePath(k,c);if(!i.pathExists(F))return s.warn(`Font file missing: ${F} \u2014 dropping from CSS`),"url(data:,)";if(!u.has(k)){let _=i.resolvePath(k,t);i.copySync(F,_,{overwrite:!0}),u.add(k)}return`url(/${$e}/${k})`})})],copiedFiles:u}}function xt({debug:i=!1,force:e=!1,languages:t}={}){let s=C("font-copy",i,!1),r=y.getInstance(),o=r.resolveAppPath(`public/${Te}`);if(!e&&r.pathExists(o)){s.debug("dndev-fonts.css already exists, skipping font copy");return}let a=r.resolveFrameworkPackage("@donotdev/ui");if(!a){s.debug("@donotdev/ui not found, skipping font copy");return}let n=r.resolveAppPath(`public/${$e}`);r.ensureDir(n);let l=t?.length?Ts(t):null;l&&s.debug(`Font copy: locale-aware filtering \u2014 locales=[${t.join(",")}] subsets=[${[...l].join(",")}]`);let p=Is(r,a),c,u;if(p.length>0?(s.debug(`Monorepo mode: ${p.length} @fontsource imports found`),{cssChunks:c,copiedFiles:u}=Ms(r,p,n,s,l)):(s.debug("Consumer mode: parsing dist/dndev.css for font files"),{cssChunks:c,copiedFiles:u}=Ls(r,a,n,s,l)),u.size===0){s.debug("No font files found to copy");return}r.writeSync(o,c.join(`
|
|
6
|
+
`)),s.debug(`Font copy: wrote ${Te} (${u.size} font files copied)`)}function Rt(){let i=y.getInstance(),e=i.resolveAppPath(`public/${Te}`),t=i.resolveAppPath(`public/${$e}`);if(i.pathExists(e))try{i.removeSync(e)}catch{}if(i.pathExists(t))try{i.removeSync(t)}catch{}}var zs=["public/route-manifest.json","public/theme-manifest.json","public/i18n-manifest.json","public/asset-manifest.json","public/seo-manifest.json","public/pwa-manifest.json","public/dndev-fonts.css","public/robots.txt","public/sitemap.xml","public/rss.xml","public/llms.txt","public/llms-full.txt"],Us="dndev-config-",kt=".dndev-build";function Ie(i){if(!i)return!1;let e=y.getInstance(),t=e.resolveAppPath(kt),s=process.env.DNDEV_BUILD_ID;try{return(e.readSync(t,{format:"text"})||"").trim()===s}catch{return!1}}function Gs(i){if(!i)return;let e=y.getInstance(),t=e.resolveAppPath(kt),s=process.env.DNDEV_BUILD_ID;try{e.writeSync(t,s)}catch{}}function Bs(i,e){if(!i)return;let t=y.getInstance();for(let r of zs){let o=t.resolveAppPath(r);if(t.pathExists(o))try{t.removeSync(o),e.debug(`Cleaned: ${r}`)}catch{}}Rt();let s=t.resolveAppPath("src/config");if(t.pathExists(s))try{let r=t.readdirSync(s);for(let o of r)if(o.startsWith(Us)&&o.endsWith(".js"))try{let a=t.resolvePath(o,s);t.removeSync(a),e.debug(`Cleaned: src/config/${o}`)}catch{}}catch{}}async function _t({routeHandler:i,themeHandler:e,i18nHandler:t,assetHandler:s,seoHandler:r,pwaHandler:o,blogContentHandler:a},n){let l=i?.pathResolver;if(!l)throw new Error("PathResolver not available - handlers must be initialized with PathResolver");let p=l.getAppRoot(),c=l.getRepoRoot();if(!p||p===c){n.warn("\u26A0\uFE0F App root not properly set before discovery - waiting for appRoot resolution"),await new Promise(m=>setTimeout(m,0));let d=l.getAppRoot();if(!d||d===c)throw new Error("App root not set before discovery. Ensure resolveAppRoot() is called before runDiscoveries().")}if(Ie(p)){n.debug("Discoveries already completed this build, skipping");return}Gs(p),Bs(p,n);let u=Date.now();if(i)try{n.info("\u{1F50D} Starting route discovery...");let m=(await i.generateFiles())?.routes?.length||0;n.info(`\u2705 Routes generated: ${m} routes found`),m===0&&n.error("\u274C NO ROUTES FOUND! Check that pages exist in src/pages/")}catch(d){throw n.error(`\u274C Route generation failed: ${d.message}`),d.stack&&n.error(`Stack: ${d.stack}`),d}else n.warn("\u26A0\uFE0F Route handler is disabled - no routes will be discovered");let g=[{name:"Theme",handler:e},{name:"I18n",handler:t},{name:"Asset",handler:s},{name:"SEO",handler:r},{name:"PWA",handler:o},{name:"BlogContent",handler:a}],f;for(let{name:d,handler:m}of g)try{let $=await m.generateFiles();d==="I18n"&&$?.supportedLanguages?.length&&(f=$.supportedLanguages)}catch($){n.debug(`${d} generation failed: ${$.message}`)}try{Ws(l,n)}catch(d){n.debug(`Env config generation failed (non-critical): ${d.message}`)}try{xt({languages:f})}catch(d){n.debug(`Font copy failed (non-critical): ${d.message}`)}let h=Date.now()-u;n.verbose?.(`\u2705 All discoveries completed in ${h}ms - Next.js can now compile`)}function Ws(i,e){let t={};for(let[a,n]of Object.entries(process.env))a.startsWith("NEXT_PUBLIC_")&&n!==void 0&&(t[a]=n);let s=`// Auto-generated DnDev env config by @donotdev/config
|
|
7
7
|
// Generated at: ${new Date().toISOString()}
|
|
8
8
|
// Populates _DNDEV_CONFIG_.env with NEXT_PUBLIC_* environment variables
|
|
9
9
|
|
|
@@ -47,7 +47,7 @@ if (typeof globalThis !== 'undefined') {
|
|
|
47
47
|
|
|
48
48
|
// Export for compatibility
|
|
49
49
|
export default ${t}Config;
|
|
50
|
-
`}writeGeneratedFile(e,t,s="file"){let r=this.pathResolver.resolveAppPath(e);return this.pathResolver.writeSync(r,t),this.logger.debug(`Generated ${s}: ${r}`),r}async generateManifest(e){let t=this.createManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,JSON.stringify(t,null,2),`${this.getHandlerName().toLowerCase()} manifest`)}async generateNextEnvTypes(){try{let e=this.pathResolver.resolveAppPath("next-env.d.ts"),t=this.pathResolver.readSync(e,{format:"text"});t&&(this.writeGeneratedFile("next-env.d.ts",t,"Next.js environment types"),this.logger.debug("Generated Next.js environment types"))}catch(e){this.logger.debug(`Could not generate Next.js environment types: ${e.message}`)}}applyViteIgnorePlugin(e,t){return e.plugins=e.plugins||[],e.plugins.push(new t.IgnorePlugin({resourceRegExp:/^vite$/})),e.plugins.push(new t.IgnorePlugin({resourceRegExp:/^@vitejs\//})),e.plugins.push(new t.IgnorePlugin({resourceRegExp:/vite/,contextRegExp:/node_modules/})),e}mergeRewrites(e,t){let s={beforeFiles:t?.beforeFiles||[],afterFiles:t?.afterFiles||[],fallback:t?.fallback||[]};return{beforeFiles:[...Array.isArray(e)?[]:e?.beforeFiles||[],...s.beforeFiles],afterFiles:[...Array.isArray(e)?e:e?.afterFiles||[],...s.afterFiles],fallback:[...Array.isArray(e)?[]:e?.fallback||[],...s.fallback]}}async _generateFiles(){return this.generateFiles()}getHandlerName(){throw new Error("getHandlerName() must be implemented by subclass")}async getDiscoveryData(){throw new Error("getDiscoveryData() must be implemented by subclass")}async generateSpecificFiles(e){throw new Error("generateSpecificFiles() must be implemented by subclass")}async generateAPIHandler(e){return Promise.resolve()}getAPIRewrites(){throw new Error("getAPIRewrites() must be implemented by subclass")}formatAPIResponse(e){throw new Error("formatAPIResponse() must be implemented by subclass")}createManifestContent(e){throw new Error("createManifestContent() must be implemented by subclass")}getGenerationSummary(e){throw new Error("getGenerationSummary() must be implemented by subclass")}};var $e=class extends G{constructor(e,t={}){super(e,{assets:z.assets.fallback,assetPatterns:z.assets.patterns,frameworkPackage:Ce.package,assetsPath:Ce.assetsPath,modernFormats:z.assets.modern,...t}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(t),r=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(r)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let a=[],n=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(n)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(t))?.generated||[]);let{consumerFiles:l}=e,p=await this._processAssetFiles(l),c=this._buildAssetManifest(p),u=await this._readLogoSvgContent("/logo.svg",t);return{assets:p,manifest:{...c,logoSvgContent:u},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(p)}}_extractPWAIcons(e){let t=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return e.filter(s=>{let r=s.path.split("/").pop()||"";return t.some(o=>o.test(r))}).map(s=>{let r=s.path.split("/").pop()||"",o=r.match(/(\d+)x(\d+)/),a=o?{width:parseInt(o[1]),height:parseInt(o[2])}:this._getDefaultIconSize(r);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(r)}})}_getDefaultIconSize(e){return e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(e){return e.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(e){return e.includes("maskable")||e.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let e=this.cache?.assets?.length||0,t=this.cache?.copiedAssets?.length||0;return`${e} assets, ${t} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,t){let s=this.getAssets().map(o=>o.path),r=t||this.options.modernFormats;for(let o of r){let a=`/${e}.${o}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let t=[];try{let s=await this._resolveFrameworkAssetsDir(e);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),t;let r=this.pathResolver.resolveAppPath(ue.public);this.pathResolver.pathExists(r)||(this.pathResolver.mkdir(r),this.logger.debug(`Created public directory: ${r}`));for(let o of this.options.assets)await this._ensureAsset(o,r,s)&&t.push(o);t.length>0&&this.logger.debug(`Added ${t.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return t}async _ensureAsset(e,t,s){let r=this.pathResolver.resolveAppPath(`${ue.public}/${e}`);if(this.pathResolver.pathExists(r))return this.logger.debug(`Asset exists: ${e}`),!1;let o=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(o)){if(await this.pathResolver.copy(o,r))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _processAssetFiles(e){let t=[];for(let s of e)try{let r=this.pathResolver.getFileInfo(s);if(r&&r.isFile){let o=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(o,r.size);a&&t.push(a)}}catch(r){this.logger.debug(`Error processing asset file ${s}: ${r.message}`)}return this.logger.debug(`Processed ${t.length} assets from ${e.length} files`),t}_analyzeAsset(e,t){let s=this._determineAssetType(e),r=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:r,size:t,sizeFormatted:this._formatBytes(t),isModern:this.options.modernFormats.includes(r)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let t=e.toLowerCase();if(t.includes("favicon"))return"favicon";if(t.includes("logo"))return"logo";if(t.includes("icon"))return"icon";if(t.includes("apple-touch"))return"apple-touch-icon";if(t.includes("android-chrome"))return"android-icon";if(t.includes("manifest"))return"manifest";let s=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(e){return e.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(e){if(e===0)return"0 Bytes";let t=1024,s=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+s[r]}_matchesPattern(e,t){let s=e.toLowerCase(),r=t.toLowerCase();return s.includes(r.replace("*",""))}_buildAssetManifest(e){let t=e.map(r=>r.path);return{logo:{optimal:this._getOptimalAsset("logo",t,this.options.modernFormats),fallback:this._getOptimalAsset("logo",t,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",t,["svg","ico"]),fallback:this._getOptimalAsset("favicon",t,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",t,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",t,["png"]),512:this._getOptimalAsset("android-chrome-512x512",t,["png"])},manifest:t.find(r=>r.includes("manifest.json"))||null,modernFormats:e.filter(r=>r.isModern).map(r=>r.path),fallbackFormats:e.filter(r=>!r.isModern).map(r=>r.path)}}_getOptimalAsset(e,t,s){for(let r of s){let o=`/${e}.${r}`;if(t.includes(o))return o}return null}async _resolveFrameworkAssetsDir(e){try{let t=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",t);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let r=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(r)?(this.logger.debug(`Using framework assets from: ${r}`),r):(this.logger.debug(`Assets directory not found: ${r}`),null)}catch(t){return this.logger.debug(`Error resolving framework assets directory: ${t.message}`),null}}async _resolvePackage(e,t){try{let s=this.pathResolver.resolveFrameworkPackage(e,t);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${e} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${e}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(e,t){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),r=this.pathResolver.resolveAppPath(`${ue.public}/${s}`);return this.pathResolver.pathExists(r)&&await this.pathResolver.read(r,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let t=await this._resolveFrameworkAssetsDir(e);if(!t)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${t}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let r=this.pathResolver.resolveAppPath(ue.public);this.pathResolver.pathExists(r)||this.pathResolver.mkdir(r);let o=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,o)}catch(t){return this.logger.debug(`Failed to copy framework logo: ${t.message}`),!1}}async _generateMissingAssets(e){let t=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(t))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let r=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],o=[{name:"favicon.svg",format:"svg"}],a=[],n=[];try{let l=await this.pathResolver.read(t,{format:"text"});if(!l)return{generated:[],skipped:[...o,...r].map(c=>c.name),error:"Failed to read logo.svg"};for(let c of o){let u=`${s}/${c.name}`;if(this.pathResolver.pathExists(u)){n.push(c.name);continue}try{await this.pathResolver.write(`public/${c.name}`,l),a.push(c.name)}catch(g){this.logger.debug(`Failed to copy ${c.name}: ${g.message}`),n.push(c.name)}}let p=await import("sharp").catch(()=>null);if(!p)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),n.push(...r.map(c=>c.name));else for(let c of r){let u=`${s}/${c.name}`;if(this.pathResolver.pathExists(u)){n.push(c.name);continue}try{let g=p.default(t).resize(c.size,c.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),f;c.format==="ico"?f=await g.toFormat("png").toBuffer():f=await g.toFormat(c.format).toBuffer(),await this.pathResolver.write(`public/${c.name}`,f),a.push(c.name)}catch(g){this.logger.debug(`Failed to generate ${c.name}: ${g.message}`),n.push(c.name)}}return{generated:a,skipped:n,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(p=>p.name),error:l.message}}}};var je={data:null},Me=class extends N{constructor(e={}){super($e,e)}getHandlerDefaults(){return{manifestPath:D.next.assetManifest,generateManifest:!0,optimizeImages:!0,modernFormats:["webp","avif","png","jpg","jpeg"]}}createDiscovery(e){return new e(this.pathResolver,this.options)}getHandlerName(){return"Asset"}generateConfigContent(e){let t=e.manifest?.logoSvgContent||null;return`// Auto-generated DnDev config by @donotdev/config
|
|
50
|
+
`}writeGeneratedFile(e,t,s="file"){let r=this.pathResolver.resolveAppPath(e);return this.pathResolver.writeSync(r,t),this.logger.debug(`Generated ${s}: ${r}`),r}async generateManifest(e){let t=this.createManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,JSON.stringify(t,null,2),`${this.getHandlerName().toLowerCase()} manifest`)}async generateNextEnvTypes(){try{let e=this.pathResolver.resolveAppPath("next-env.d.ts"),t=this.pathResolver.readSync(e,{format:"text"});t&&(this.writeGeneratedFile("next-env.d.ts",t,"Next.js environment types"),this.logger.debug("Generated Next.js environment types"))}catch(e){this.logger.debug(`Could not generate Next.js environment types: ${e.message}`)}}applyViteIgnorePlugin(e,t){return e.plugins=e.plugins||[],e.plugins.push(new t.IgnorePlugin({resourceRegExp:/^vite$/})),e.plugins.push(new t.IgnorePlugin({resourceRegExp:/^@vitejs\//})),e.plugins.push(new t.IgnorePlugin({resourceRegExp:/vite/,contextRegExp:/node_modules/})),e}mergeRewrites(e,t){let s={beforeFiles:t?.beforeFiles||[],afterFiles:t?.afterFiles||[],fallback:t?.fallback||[]};return{beforeFiles:[...Array.isArray(e)?[]:e?.beforeFiles||[],...s.beforeFiles],afterFiles:[...Array.isArray(e)?e:e?.afterFiles||[],...s.afterFiles],fallback:[...Array.isArray(e)?[]:e?.fallback||[],...s.fallback]}}async _generateFiles(){return this.generateFiles()}getHandlerName(){throw new Error("getHandlerName() must be implemented by subclass")}async getDiscoveryData(){throw new Error("getDiscoveryData() must be implemented by subclass")}async generateSpecificFiles(e){throw new Error("generateSpecificFiles() must be implemented by subclass")}async generateAPIHandler(e){return Promise.resolve()}getAPIRewrites(){throw new Error("getAPIRewrites() must be implemented by subclass")}formatAPIResponse(e){throw new Error("formatAPIResponse() must be implemented by subclass")}createManifestContent(e){throw new Error("createManifestContent() must be implemented by subclass")}getGenerationSummary(e){throw new Error("getGenerationSummary() must be implemented by subclass")}};var Se=class extends G{constructor(e,t={}){super(e,{assets:z.assets.fallback,assetPatterns:z.assets.patterns,frameworkPackage:Ce.package,assetsPath:Ce.assetsPath,modernFormats:z.assets.modern,...t}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let t=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(t),r=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(r)||this.logger.warn("logo.svg not found in public/. Add your logo.svg to generate PWA assets, or copy from node_modules/@donotdev/ui/assets/logo.svg");let a=[],n=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(n)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(t))?.generated||[]);let{consumerFiles:l}=e,p=await this._processAssetFiles(l),c=this._buildAssetManifest(p),u=await this._readLogoSvgContent("/logo.svg",t);return{assets:p,manifest:{...c,logoSvgContent:u},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(p)}}_extractPWAIcons(e){let t=[/icon-(\d+)x(\d+)\.(png|jpg|jpeg|webp|svg)/i,/apple-touch-icon/i,/android-chrome/i,/favicon\.(ico|svg)/i];return e.filter(s=>{let r=s.path.split("/").pop()||"";return t.some(o=>o.test(r))}).map(s=>{let r=s.path.split("/").pop()||"",o=r.match(/(\d+)x(\d+)/),a=o?{width:parseInt(o[1]),height:parseInt(o[2])}:this._getDefaultIconSize(r);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(r)}})}_getDefaultIconSize(e){return e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("favicon")?{width:32,height:32}:{width:192,height:192}}_getFormatFromPath(e){return e.split(".").pop()?.toLowerCase()||"png"}_getIconPurpose(e){return e.includes("maskable")||e.includes("mask")?"maskable":"any"}_getEmptyResult(){return{assets:[],manifest:this._getEmptyManifest(),copiedAssets:[],timestamp:Date.now()}}_getDiscoverySummary(){let e=this.cache?.assets?.length||0,t=this.cache?.copiedAssets?.length||0;return`${e} assets, ${t} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,t){let s=this.getAssets().map(o=>o.path),r=t||this.options.modernFormats;for(let o of r){let a=`/${e}.${o}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let t=[];try{let s=await this._resolveFrameworkAssetsDir(e);if(this.logger.debug(`Framework assets directory resolved to: ${s}`),!s)return this.logger.debug("Framework assets directory not found, skipping defaults"),t;let r=this.pathResolver.resolveAppPath(ue.public);this.pathResolver.pathExists(r)||(this.pathResolver.mkdir(r),this.logger.debug(`Created public directory: ${r}`));for(let o of this.options.assets)await this._ensureAsset(o,r,s)&&t.push(o);t.length>0&&this.logger.debug(`Added ${t.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return t}async _ensureAsset(e,t,s){let r=this.pathResolver.resolveAppPath(`${ue.public}/${e}`);if(this.pathResolver.pathExists(r))return this.logger.debug(`Asset exists: ${e}`),!1;let o=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(o)){if(await this.pathResolver.copy(o,r))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _processAssetFiles(e){let t=[];for(let s of e)try{let r=this.pathResolver.getFileInfo(s);if(r&&r.isFile){let o=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(o,r.size);a&&t.push(a)}}catch(r){this.logger.debug(`Error processing asset file ${s}: ${r.message}`)}return this.logger.debug(`Processed ${t.length} assets from ${e.length} files`),t}_analyzeAsset(e,t){let s=this._determineAssetType(e),r=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:r,size:t,sizeFormatted:this._formatBytes(t),isModern:this.options.modernFormats.includes(r)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let t=e.toLowerCase();if(t.includes("favicon"))return"favicon";if(t.includes("logo"))return"logo";if(t.includes("icon"))return"icon";if(t.includes("apple-touch"))return"apple-touch-icon";if(t.includes("android-chrome"))return"android-icon";if(t.includes("manifest"))return"manifest";let s=e.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","webp","avif","svg"].includes(s)?"image":["woff2","woff","ttf","otf"].includes(s)?"font":["json"].includes(s)?"json":["ico"].includes(s)?"icon":"unknown"}_determineAssetFormat(e){return e.split(".").pop()?.toLowerCase()||"unknown"}_formatBytes(e){if(e===0)return"0 Bytes";let t=1024,s=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+s[r]}_matchesPattern(e,t){let s=e.toLowerCase(),r=t.toLowerCase();return s.includes(r.replace("*",""))}_buildAssetManifest(e){let t=e.map(r=>r.path);return{logo:{optimal:this._getOptimalAsset("logo",t,this.options.modernFormats),fallback:this._getOptimalAsset("logo",t,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",t,["svg","ico"]),fallback:this._getOptimalAsset("favicon",t,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",t,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",t,["png"]),512:this._getOptimalAsset("android-chrome-512x512",t,["png"])},manifest:t.find(r=>r.includes("manifest.json"))||null,modernFormats:e.filter(r=>r.isModern).map(r=>r.path),fallbackFormats:e.filter(r=>!r.isModern).map(r=>r.path)}}_getOptimalAsset(e,t,s){for(let r of s){let o=`/${e}.${r}`;if(t.includes(o))return o}return null}async _resolveFrameworkAssetsDir(e){try{let t=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",t);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let r=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(r)?(this.logger.debug(`Using framework assets from: ${r}`),r):(this.logger.debug(`Assets directory not found: ${r}`),null)}catch(t){return this.logger.debug(`Error resolving framework assets directory: ${t.message}`),null}}async _resolvePackage(e,t){try{let s=this.pathResolver.resolveFrameworkPackage(e,t);return s?(this.logger.debug(`Found package: ${s}`),s):(this.logger.debug(`Package ${e} not found`),null)}catch(s){return this.logger.debug(`Error resolving package ${e}: ${s.message}`),null}}_getEmptyManifest(){return{logo:{optimal:null,fallback:null},favicon:{optimal:null,fallback:null},appleTouchIcon:null,androidChrome:{192:null,512:null},manifest:null,modernFormats:[],fallbackFormats:[],logoSvgContent:null}}async _readLogoSvgContent(e,t){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),r=this.pathResolver.resolveAppPath(`${ue.public}/${s}`);return this.pathResolver.pathExists(r)&&await this.pathResolver.read(r,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let t=await this._resolveFrameworkAssetsDir(e);if(!t)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${t}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let r=this.pathResolver.resolveAppPath(ue.public);this.pathResolver.pathExists(r)||this.pathResolver.mkdir(r);let o=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,o)}catch(t){return this.logger.debug(`Failed to copy framework logo: ${t.message}`),!1}}async _generateMissingAssets(e){let t=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(t))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let r=[{name:"favicon.ico",size:32,format:"ico"},{name:"apple-touch-icon.png",size:180,format:"png"},{name:"icon-192x192.png",size:192,format:"png"},{name:"icon-512x512.png",size:512,format:"png"}],o=[{name:"favicon.svg",format:"svg"}],a=[],n=[];try{let l=await this.pathResolver.read(t,{format:"text"});if(!l)return{generated:[],skipped:[...o,...r].map(c=>c.name),error:"Failed to read logo.svg"};for(let c of o){let u=`${s}/${c.name}`;if(this.pathResolver.pathExists(u)){n.push(c.name);continue}try{await this.pathResolver.write(`public/${c.name}`,l),a.push(c.name)}catch(g){this.logger.debug(`Failed to copy ${c.name}: ${g.message}`),n.push(c.name)}}let p=await import("sharp").catch(()=>null);if(!p)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),n.push(...r.map(c=>c.name));else for(let c of r){let u=`${s}/${c.name}`;if(this.pathResolver.pathExists(u)){n.push(c.name);continue}try{let g=p.default(t).resize(c.size,c.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),f;c.format==="ico"?f=await g.toFormat("png").toBuffer():f=await g.toFormat(c.format).toBuffer(),await this.pathResolver.write(`public/${c.name}`,f),a.push(c.name)}catch(g){this.logger.debug(`Failed to generate ${c.name}: ${g.message}`),n.push(c.name)}}return{generated:a,skipped:n,error:null}}catch(l){return this.logger.debug(`Asset generation failed: ${l.message}`),{generated:[],skipped:requiredAssets.map(p=>p.name),error:l.message}}}};var je={data:null},Me=class extends N{constructor(e={}){super(Se,e)}getHandlerDefaults(){return{manifestPath:D.next.assetManifest,generateManifest:!0,optimizeImages:!0,modernFormats:["webp","avif","png","jpg","jpeg"]}}createDiscovery(e){return new e(this.pathResolver,this.options)}getHandlerName(){return"Asset"}generateConfigContent(e){let t=e.manifest?.logoSvgContent||null;return`// Auto-generated DnDev config by @donotdev/config
|
|
51
51
|
// Generated at: ${new Date().toISOString()}
|
|
52
52
|
// Populates _DNDEV_CONFIG_ with discovery results
|
|
53
53
|
|
|
@@ -276,12 +276,12 @@ if (typeof globalThis !== 'undefined') {
|
|
|
276
276
|
export const routes = routeMapping;
|
|
277
277
|
export const manifest = routeManifest;
|
|
278
278
|
export default { routes: routeMapping, manifest: routeManifest };
|
|
279
|
-
`}async generateSpecificFiles(e){this.options.generateMiddleware&&await this.generateMiddleware(e),await this.generateMetadataManifest(e),this.options.generateAppPages&&await this.generateAppPageFiles(e),this.options.routingMode==="app"?await this.generateAppRoutes(e):await this.generatePagesRoutes(e),await this.generateAPIHandler(e)}async generateMetadataManifest(e){let t=this.loadI18nConfig(),s=He(t),r=Ve(t),o=process.env.NEXT_PUBLIC_SITE_NAME||"";if(!o)try{let l=this.pathResolver.resolveAppPath("public/seo-manifest.json");this.pathResolver.pathExists(l)&&(o=this.pathResolver.readSync(l,{format:"json"})?.siteName||"")}catch{}let a={};for(let l of e.routes){let p=l.metaExport?.namespace,c=l.metaExport?.seo||{},u={};for(let g of s){let f=p&&t&&We(p,g,t,this.pathResolver)||We(p,r,t,this.pathResolver),h=Re(f,"meta")||{},d=Re(f,"title"),m=Re(f,"description")
|
|
279
|
+
`}async generateSpecificFiles(e){this.options.generateMiddleware&&await this.generateMiddleware(e),await this.generateMetadataManifest(e),this.options.generateAppPages&&await this.generateAppPageFiles(e),this.options.routingMode==="app"?await this.generateAppRoutes(e):await this.generatePagesRoutes(e),await this.generateAPIHandler(e)}async generateMetadataManifest(e){let t=this.loadI18nConfig(),s=He(t),r=Ve(t),o=process.env.NEXT_PUBLIC_SITE_NAME||"";if(!o)try{let l=this.pathResolver.resolveAppPath("public/seo-manifest.json");this.pathResolver.pathExists(l)&&(o=this.pathResolver.readSync(l,{format:"json"})?.siteName||"")}catch{}let a={};for(let l of e.routes){let p=l.metaExport?.namespace,c=l.metaExport?.seo||{},u={};for(let g of s){let f=p&&t&&We(p,g,t,this.pathResolver)||We(p,r,t,this.pathResolver),h=Re(f,"meta")||{},d=Re(f,"title"),m=Re(f,"description"),$;h.fullTitle?$=h.fullTitle:c.fullTitle?$=c.fullTitle:d?$=o?`${d} | ${o}`:d:c.title?$=o?`${c.title} | ${o}`:c.title:c.title===null?$=o:$=o||"";let k;c.description===null?k=void 0:c.description?k=c.description:m&&(k=m);let F=c.image||h.image||"/og-image.png",I=c.type||h.type||"website",_=c.keywords||h.keywords,H=c.noindex||!1;u[g]={title:$,...k&&{description:k},image:F,type:I,..._&&{keywords:_},...H&&{noindex:H}}}a[l.path]={locales:u,defaultLocale:r}}let n=JSON.stringify(a,null,2);this.writeGeneratedFile("public/metadata-manifest.json",n,"metadata manifest"),this.logger.debug(`Generated metadata manifest for ${Object.keys(a).length} routes`)}async generateAppPageFiles(e){this.logger.debug("Starting app/** page file generation");try{await this.cleanGeneratedPageFiles();let t=0;for(let s of e.routes)await this.generateSingleAppPage(s)&&t++;this.logger.debug(`Successfully generated ${t}/${e.routes.length} app/** page files`)}catch(t){throw this.logger.error(`Failed to generate app/** files: ${t.message}`),t}}async cleanGeneratedPageFiles(){try{let e=this.pathResolver.getAppRoot(),t=["src/app/**/page.tsx","src/app/[...slug]/page.tsx"],s=await this.pathResolver._globWithNormalization(t,{cwd:e,absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0}),r=0;for(let o of s)if(await this.hasGenerationMarker(o))try{await this.pathResolver.remove(o),r++,this.logger.debug(`Cleaned generated file: ${o}`)}catch(a){this.logger.debug(`Could not clean file ${o}: ${a.message}`)}r>0&&this.logger.debug(`Cleaned ${r} existing generated page files`)}catch(e){this.logger.debug(`Error during cleanup: ${e.message}`)}}async generateSingleAppPage(e){try{let t=this.convertRouteToAppPath(e.path),s=`src/app${t}/page.tsx`,r=this.pathResolver.resolveAppPath(s);if(this.pathResolver.pathExists(r)&&!await this.hasGenerationMarker(r))return this.logger.debug(`Skipping ${s} - user-created file detected (no generation marker)`),!1;let o={...e,filePath:e.file||e.filePath||this.pathResolver.resolveAppPath(e.file),relativePath:e.file||e.relativePath},a=this.generatePageFileContent(o);this.writeGeneratedFile(s,a,`app page: ${t}`);let n=this.extractComponentName(o.filePath),l=this.calculateRelativeImportPath(o.relativePath,o.path);return o.metaExport?.namespace==="blog"&&this.hasDynamicSegment(o.path)?this.writeGeneratedFile(`src/app${t}/BlogPostClient.tsx`,this.generateBlogPostClientContent(n,l),`app blog client: ${t}`):this.isClientComponent(o.filePath)&&this.writeGeneratedFile(`src/app${t}/${n}Client.tsx`,this.generateMountedClientContent(n,l),`app client wrapper: ${t}`),!0}catch(t){return this.logger.debug(`Error generating page for route ${e.path}: ${t.message}`),!1}}convertRouteToAppPath(e){if(e===pe.HOMEPAGE_PATH)return"";let t=e;return t.startsWith("/")||(t="/"+t),t=t.replace(/\/+/g,"/"),t.split("/").map(s=>s.startsWith(":")?`[${s.slice(1)}]`:s==="*"?"[...slug]":s).join("/")}loadI18nConfig(){try{let e=this.pathResolver.resolveAppPath("src/config/dndev-config-i18n.js");if(!this.pathResolver.pathExists(e))return this.logger.debug("I18n config file not found, skipping metadata generation"),null;if(typeof globalThis<"u"&&globalThis._DNDEV_CONFIG_?.i18n)return globalThis._DNDEV_CONFIG_.i18n;try{let t=this.pathResolver.getAppRoot(),s=qs(t),r=s.resolve(e);delete s.cache[r];let o=s(r);return o.default||o.i18nConfig||o}catch(t){return this.logger.debug(`Failed to require i18n config: ${t.message}`),null}}catch(e){return this.logger.debug(`Failed to load i18n config: ${e.message}`),null}}generatePageFileContent(e){let t=this.extractComponentName(e.filePath),s=e.relativePath||e.file,r=this.calculateRelativeImportPath(s,e.path);return e.metaExport?.namespace==="blog"&&this.hasDynamicSegment(e.path)?this.generateBlogPostRSCContent(e,t,r):this.isClientComponent(e.filePath)?`// Generated by @donotdev/config - DO NOT EDIT
|
|
280
280
|
// This file will be regenerated when src/pages changes
|
|
281
281
|
// To customize: edit ${e.filePath} or create manual app/** files
|
|
282
282
|
|
|
283
283
|
import ${t}Client from './${t}Client';
|
|
284
|
-
|
|
284
|
+
${this.ssrDynamicExport()}
|
|
285
285
|
export default function ${t}Route() {
|
|
286
286
|
return <${t}Client />;
|
|
287
287
|
}
|
|
@@ -294,13 +294,17 @@ import type { Metadata } from 'next';
|
|
|
294
294
|
import { getMetadataForPath } from '@donotdev/core/next';
|
|
295
295
|
|
|
296
296
|
import ${t} from '${r}';
|
|
297
|
-
|
|
297
|
+
${this.ssrDynamicExport()}
|
|
298
298
|
export async function generateMetadata(): Promise<Metadata> {
|
|
299
299
|
return getMetadataForPath('${e.path}');
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
export default ${t};
|
|
303
|
-
`}
|
|
303
|
+
`}ssrDynamicExport(){return this.options.ssr?`
|
|
304
|
+
// SSR (appConfig.ssr): render at request time \u2014 the provider tree is store-driven
|
|
305
|
+
// and therefore dynamic. Content is fully server-rendered.
|
|
306
|
+
export const dynamic = 'force-dynamic';
|
|
307
|
+
`:""}generateMetadataFunction(e,t,s){let r=He(s),o=Ve(s),a="`",n=r.map(l=>` '${l}': { href: ${a}\${baseUrl}\${currentPath}${a} }`).join(`,
|
|
304
308
|
`);return`
|
|
305
309
|
import type { Metadata } from 'next';
|
|
306
310
|
import { readFileSync } from 'node:fs';
|
|
@@ -520,7 +524,16 @@ export const routeManifest = {
|
|
|
520
524
|
};
|
|
521
525
|
|
|
522
526
|
export default pageRoutes;
|
|
523
|
-
`}pathToComponentName(e){return e.split("/").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")+"Page"}calculateRelativeImportPath(e,t){if(!e)throw new Error("relativePath is required for import path calculation");let r=e.replace(/\.tsx$/,"").replace(/^src\//,""),o=t==="/"?0:t.split("/").filter(Boolean).length;return`${"../".repeat(o+1)}${r}`}hasDynamicSegment(e){return e.includes(":")||e.includes("[")}extractDynamicParam(e){let t=e.match(/:([a-zA-Z0-9_]+)/);if(t)return t[1];let s=e.match(/\[([^\]]+)\]/);return s?s[1]:"slug"}generateMountedClientContent(e,t){return
|
|
527
|
+
`}pathToComponentName(e){return e.split("/").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")+"Page"}calculateRelativeImportPath(e,t){if(!e)throw new Error("relativePath is required for import path calculation");let r=e.replace(/\.tsx$/,"").replace(/^src\//,""),o=t==="/"?0:t.split("/").filter(Boolean).length;return`${"../".repeat(o+1)}${r}`}hasDynamicSegment(e){return e.includes(":")||e.includes("[")}extractDynamicParam(e){let t=e.match(/:([a-zA-Z0-9_]+)/);if(t)return t[1];let s=e.match(/\[([^\]]+)\]/);return s?s[1]:"slug"}generateMountedClientContent(e,t){return this.options.ssr?`// Generated by @donotdev/config - DO NOT EDIT
|
|
528
|
+
// This file will be regenerated when src/pages changes
|
|
529
|
+
'use client';
|
|
530
|
+
|
|
531
|
+
import ${e} from '${t}';
|
|
532
|
+
|
|
533
|
+
export default function ${e}Client() {
|
|
534
|
+
return <${e} />;
|
|
535
|
+
}
|
|
536
|
+
`:`// Generated by @donotdev/config - DO NOT EDIT
|
|
524
537
|
// This file will be regenerated when src/pages changes
|
|
525
538
|
'use client';
|
|
526
539
|
|
|
@@ -787,6 +800,6 @@ export function useTheme() {
|
|
|
787
800
|
}
|
|
788
801
|
|
|
789
802
|
export default useTheme;
|
|
790
|
-
`}};function Yt(i={}){return new Xe(i)}function Kt({debug:i,verbose:e,generateManifest:t,routeOptions:s,themeOptions:r,i18nOptions:o,assetOptions:a,seoOptions:n,pwaOptions:l,serverShimOptions:p,appUrl:c,isDev:u,logger:g}){let f=s.debug??i,h=r.debug??i,d=o.debug??i,m=a.debug??i
|
|
791
|
-
\u{1F3D7}\uFE0F DnDev Framework - Building for ${k}${s?` [build:${s}]`:""}`)
|
|
792
|
-
`)}if(F){let P=process.env.PORT||3e3;process.env.NEXT_PUBLIC_APP_URL=`http://localhost:${P}`,m&&(
|
|
803
|
+
`}};function Yt(i={}){return new Xe(i)}function Kt({debug:i,verbose:e,generateManifest:t,routeOptions:s,themeOptions:r,i18nOptions:o,assetOptions:a,seoOptions:n,pwaOptions:l,serverShimOptions:p,appUrl:c,isDev:u,logger:g}){let f=s.debug??i,h=r.debug??i,d=o.debug??i,m=a.debug??i,$=n.debug??i,k=l.debug??i,F=p.debug??i,I=s.verbose??e,_=r.verbose??e,H=o.verbose??e,M=a.verbose??e,q=n.verbose??e,re=l.verbose??e,Q=p.verbose??e,w={debug:i,verbose:e,generateManifest:t},S=s.disabled?null:zt({...w,...s,debug:f,verbose:I});i&&g.debug(`Route handler created: ${S?"enabled":"disabled"} (debug: ${f})`);let ee=Yt({...w,...r,debug:h,verbose:_}),j=Tt({...w,...o,debug:d,verbose:H}),K=Dt({...w,...a,debug:m,verbose:M}),V=Ht({...w,...n,debug:$,verbose:q,appUrl:c,isDev:u}),O=It({...w,...l,debug:k,verbose:re}),B=Vt({...w,...p,debug:F,verbose:Q}),v=Ot({debug:i,verbose:e});return{routeHandler:S,themeHandler:ee,i18nHandler:j,assetHandler:K,seoHandler:V,pwaHandler:O,serverShimHandler:B,blogContentHandler:v}}function Xt(i,e){let t={};if(i.routeHandler)try{t.routeConfig=i.routeHandler.createNextConfig()}catch(r){e.error(`Route handler failed during config creation: ${r.message}`),e.error(`Stack: ${r.stack||"No stack trace available"}`),t.routeConfig=()=>({})}else t.routeConfig=()=>({});let s=[{name:"theme",handler:i.themeHandler},{name:"i18n",handler:i.i18nHandler},{name:"asset",handler:i.assetHandler},{name:"seo",handler:i.seoHandler},{name:"pwa",handler:i.pwaHandler}];for(let{name:r,handler:o}of s)try{t[`${r}Config`]=o.createNextConfig()}catch(a){e.error(`${r.charAt(0).toUpperCase()+r.slice(1)} handler failed: ${a.message}`),e.error(`Stack: ${a.stack||"No stack trace available"}`),t[`${r}Config`]=()=>({})}try{t.serverShimConfig=i.serverShimHandler}catch(r){e.error(`ServerShim handler failed: ${r.message}`),e.error(`Stack: ${r.stack||"No stack trace available"}`),t.serverShimConfig=()=>({})}return t}var Xs=new Set(["@donotdev/functions"]);function Zt(){try{let i=y.getInstance(),e=i.resolveAppPath("package.json"),t=i.readSync(e,{format:"json"});if(!t)return[];let s={...t.dependencies,...t.devDependencies};return Object.keys(s).filter(r=>r.startsWith("@donotdev/")).filter(r=>!be.buildTimePackages.includes(r)).filter(r=>!Xs.has(r)).sort()}catch{return[]}}var Ze=new Map;function Zs(i={}){let{port:e,...t}=i;if(e&&process.env.NODE_ENV!=="production"&&(process.env.PORT=String(e)),!process.env.DNDEV_BUILD_ID){let P=process.env.CI==="true";process.env.DNDEV_BUILD_ID=P?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9)}let s=process.env.DNDEV_BUILD_ID;if(s&&Ze.has(s))return Ze.get(s).configFn;let{appConfig:r,...o}=t;if(!r)throw new Error("appConfig is required. Import appConfig from src/config/app.ts and pass it to defineNextConfig({ appConfig, ... })");let a=r?.features?{debug:r.features.debug}:void 0,n=r?.seo&&typeof r.seo!="boolean"?{...r.seo,siteName:r.seo.siteName||r.app?.name}:r?.app?.name?{siteName:r.app.name}:void 0,l=r?.app?{name:r.app.name,shortName:r.app.shortName,description:r.app.description}:void 0,{features:p,seo:c,...u}=o,g={...a?{features:a}:{},...n?{seo:n}:{},...u},f=Nt(g),h=Ft(f);if(!h)throw new Error("normalizeOptions returned undefined");let{generateManifest:d,debug:m,verbose:$,mode:k,isDev:F,routeOptions:I,themeOptions:_,i18nOptions:H,assetOptions:M,pwaOptions:q,seoOptions:re,serverShimOptions:Q,nextConfigOptions:w}=h,S=C("next-config",m,$),{appRoot:ee,appRootSet:j}=lt({logger:S,debug:m}),K=!1,V=j&&Ie(ee);if(!V){let P=I?.routingMode||"app";S.info(`
|
|
804
|
+
\u{1F3D7}\uFE0F DnDev Framework - Building for ${k}${s?` [build:${s}]`:""}`),S.info(` Platform: Next.js | Routing: ${P}
|
|
805
|
+
`)}if(F){let P=process.env.PORT||3e3;process.env.NEXT_PUBLIC_APP_URL=`http://localhost:${P}`,m&&(S.debug(`NEXT_PUBLIC_APP_URL: ${process.env.NEXT_PUBLIC_APP_URL}`),e&&S.debug(`Port configured: ${P} (set PORT env var)`))}else process.env.NEXT_PUBLIC_APP_URL||S.warn("NEXT_PUBLIC_APP_URL not found in environment. Set it in .env.production");let O=Kt({debug:m,verbose:$,generateManifest:d,routeOptions:{...I,ssr:r?.ssr!==!1},themeOptions:_,i18nOptions:H,assetOptions:M,seoOptions:re,pwaOptions:q,serverShimOptions:Q,isDev:F,logger:S}),B=Xt(O,S),v=async function(R={}){let x=y.getInstance(),L=j?Zt():[];m&&L.length>0&&S.debug(`Discovered ${L.length} packages: ${L.join(", ")}`);let{missing:te,installed:me}=Pe(x.getAppRoot()),Ae=te.filter(ce=>ce.startsWith("@donotdev/")),es=me.filter(ce=>ce.startsWith("@donotdev/"));m&&te.length>0&&S.debug(`Missing optional deps (will alias to empty): ${te.join(", ")}`),j&&await _t(O,S);let se=typeof R=="object"&&R!==null?R:{},{webpack:ts,rewrites:ss,redirects:rs,...os}=se;j&&!K&&(K=await At(O.assetHandler,S,K));let ns=B.routeConfig(se),as=B.themeConfig(se),is=B.i18nConfig(se),ls=B.assetConfig(se),cs=B.seoConfig(se),ps=B.pwaConfig(se),us=B.serverShimConfig(),et=(await O.i18nHandler?.getDiscoveryData?.())?.flagCodes||[],gs=bt({originalWebpack:ts,unusedFeaturePackages:Ae,usedFeaturePackages:es,missingOptionalDeps:te,flagCodes:et,logger:S,debug:m}),fs=yt({originalRewrites:ss,handlers:[O.routeHandler,O.themeHandler,O.i18nHandler,O.assetHandler,O.pwaHandler],logger:S}),hs=wt({originalRedirects:rs,seoRedirects:re?.redirects||[],logger:S}),ds={_DNDEV_CONFIG_:JSON.stringify({platform:"nextjs",mode:process.env.NODE_ENV||"development",context:"build",timestamp:Date.now()})},ms=Pt({routeResult:ns,themeResult:as,i18nResult:is,assetResult:ls,seoResult:cs,pwaResult:ps,serverShimResult:us,restNextConfig:os,discoveredPackages:L,webpackConfig:gs,rewritesConfig:fs,redirectsConfig:hs,missingOptionalDeps:te,flagCodes:et,pathResolver:x,env:ds,logger:S});if(S.debug("Next.js config generated"),j&&!V){let ce=l?.name||"app";S.info(`Name: ${ce}`),S.info(`URL: ${process.env.NEXT_PUBLIC_APP_URL||"http://localhost:3000"}`),S.info(`App root (final): ${x.getAppRoot()}`)}return ms};return s&&Ze.set(s,{configFn:v}),v}var Qt=Zs;import{readFileSync as Qs,existsSync as er}from"node:fs";import{join as tr}from"node:path";var de=null,Qe=0,sr=6e4;function rr(){let i=Date.now();if(de&&i-Qe<sr)return de;try{let e=tr(process.cwd(),"public","metadata-manifest.json");if(!er(e))return null;let t=Qs(e,"utf-8");return de=JSON.parse(t),Qe=i,de}catch{return null}}function or(i,e,t){let s=rr(),r={title:t?.siteName||"Site"};if(!s)return r;let o=i.startsWith("/")?i:`/${i}`,a=s[o];if(!a)return r;let n=e||a.defaultLocale||"en",l=a.locales[n]||a.locales[a.defaultLocale]||Object.values(a.locales)[0];if(!l)return r;let p=process.env.NEXT_PUBLIC_APP_URL,c={title:l.title,...p&&{metadataBase:new URL(p)}};return l.description&&(c.description=l.description),l.keywords&&(c.keywords=l.keywords),c.openGraph={title:l.title,type:l.type||"website",...l.description&&{description:l.description},...l.image&&{images:[l.image]},...t?.siteName&&{siteName:t.siteName}},c.twitter={card:"summary_large_image",title:l.title,...l.description&&{description:l.description},...l.image&&{images:[l.image]}},l.noindex&&(c.robots={index:!1,follow:!1}),c}function nr(){de=null,Qe=0}export{nr as clearMetadataCache,Qt as default,Qt as defineNextConfig,Ds as definePostCSSConfig,or as getMetadataForPath};
|
package/package.json
CHANGED
package/server.d.ts
CHANGED
|
@@ -2644,6 +2644,15 @@ interface AppConfig {
|
|
|
2644
2644
|
features?: FeaturesConfig;
|
|
2645
2645
|
/** Query cache configuration (defaults: 5min staleTime, refetch on focus/reconnect) */
|
|
2646
2646
|
query?: QueryConfig;
|
|
2647
|
+
/**
|
|
2648
|
+
* Server-side rendering (Next adapter). **Defaults to `true`** — generated page
|
|
2649
|
+
* wrappers render directly and the provider tree renders on the server, so page
|
|
2650
|
+
* content is present in the initial HTML (real, crawlable SSR). Set to `false`
|
|
2651
|
+
* to opt OUT and restore the legacy client-only render (content appears only
|
|
2652
|
+
* after hydration). The provider tree is store-driven, so SSR routes render
|
|
2653
|
+
* dynamically at request time.
|
|
2654
|
+
*/
|
|
2655
|
+
ssr?: boolean;
|
|
2647
2656
|
}
|
|
2648
2657
|
/**
|
|
2649
2658
|
* Custom store configuration for app-specific stores
|
package/vite/index.d.ts
CHANGED
|
@@ -649,6 +649,15 @@ interface AppConfig {
|
|
|
649
649
|
features?: FeaturesConfig;
|
|
650
650
|
/** Query cache configuration (defaults: 5min staleTime, refetch on focus/reconnect) */
|
|
651
651
|
query?: QueryConfig;
|
|
652
|
+
/**
|
|
653
|
+
* Server-side rendering (Next adapter). **Defaults to `true`** — generated page
|
|
654
|
+
* wrappers render directly and the provider tree renders on the server, so page
|
|
655
|
+
* content is present in the initial HTML (real, crawlable SSR). Set to `false`
|
|
656
|
+
* to opt OUT and restore the legacy client-only render (content appears only
|
|
657
|
+
* after hydration). The provider tree is store-driven, so SSR routes render
|
|
658
|
+
* dynamically at request time.
|
|
659
|
+
*/
|
|
660
|
+
ssr?: boolean;
|
|
652
661
|
}
|
|
653
662
|
|
|
654
663
|
// packages/core/config/index.d.ts
|