@donotdev/core 0.0.7 → 0.0.9
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 +15 -1
- package/index.js +20 -20
- package/next/index.js +2 -2
- package/package.json +2 -2
- package/server.js +25 -25
- package/vite/index.js +15 -15
package/next/index.js
CHANGED
|
@@ -23,7 +23,7 @@ if (typeof globalThis !== 'undefined') {
|
|
|
23
23
|
|
|
24
24
|
// Export for compatibility
|
|
25
25
|
export default ${r}Config;
|
|
26
|
-
`}writeGeneratedFile(e,r,s="file"){let i=this.pathResolver.resolveAppPath(e);return this.pathResolver.writeSync(i,r),this.logger.debug(`Generated ${s}: ${i}`),i}async generateManifest(e){let r=this.createManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,JSON.stringify(r,null,2),`${this.getHandlerName().toLowerCase()} manifest`)}async generateNextEnvTypes(){try{let e=this.pathResolver.resolveAppPath("next-env.d.ts"),r=this.pathResolver.readSync(e,{format:"text"});r&&(this.writeGeneratedFile("next-env.d.ts",r,"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,r){return e.plugins=e.plugins||[],e.plugins.push(new r.IgnorePlugin({resourceRegExp:/^vite$/})),e.plugins.push(new r.IgnorePlugin({resourceRegExp:/^@vitejs\//})),e.plugins.push(new r.IgnorePlugin({resourceRegExp:/vite/,contextRegExp:/node_modules/})),e}mergeRewrites(e,r){let s={beforeFiles:r?.beforeFiles||[],afterFiles:r?.afterFiles||[],fallback:r?.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")}};Q();g();g();var he=class t{constructor(e,r={}){if(this.constructor===t)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...r},p.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=me(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 r=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 i=await this._scanFiles(s),n=await this._processFiles(i);this.cache={...n,timestamp:Date.now()};let a=Date.now()-r;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 r=this._getPatternType();return await this.pathResolver.resolveFiles(e,r)}_extractFileNameInfo(e){let r=e.split("/"),s=r[r.length-1],i=s.split(".")[0],n=s.split(".").pop();return{fileName:s,baseName:i,extension:n,directory:r.slice(0,-1).join("/")}}async _processSingleFile(e,r){try{let s=this.pathResolver.getFileInfo(e);return s?await r(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,r){return(await Promise.all(e.map(i=>this._processSingleFile(i,r)))).filter(i=>i!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};Q();var Yt=class extends he{constructor(e,r={}){super(e,{assets:ce.assets.fallback,assetPatterns:ce.assets.patterns,frameworkPackage:lr.package,assetsPath:lr.assetsPath,modernFormats:ce.assets.modern,...r}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let r=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(r),i=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(i)||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=[],o=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(o)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(r))?.generated||[]);let{consumerFiles:c}=e,u=await this._processAssetFiles(c),f=this._buildAssetManifest(u),m=await this._readLogoSvgContent("/logo.svg",r);return{assets:u,manifest:{...f,logoSvgContent:m},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(u)}}_extractPWAIcons(e){let r=[/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 i=s.path.split("/").pop()||"";return r.some(n=>n.test(i))}).map(s=>{let i=s.path.split("/").pop()||"",n=i.match(/(\d+)x(\d+)/),a=n?{width:parseInt(n[1]),height:parseInt(n[2])}:this._getDefaultIconSize(i);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(i)}})}_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,r=this.cache?.copiedAssets?.length||0,s=this.cache?.copiedAssets?.filter(i=>i.startsWith("fonts/")).length||0;return s>0?`${e} assets, ${r} copied (${s} fonts)`:`${e} assets, ${r} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,r){let s=this.getAssets().map(n=>n.path),i=r||this.options.modernFormats;for(let n of i){let a=`/${e}.${n}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let r=[];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"),r;let i=this.pathResolver.resolveAppPath(Ae.public);this.pathResolver.pathExists(i)||(this.pathResolver.mkdir(i),this.logger.debug(`Created public directory: ${i}`));for(let n of this.options.assets)await this._ensureAsset(n,i,s)&&r.push(n);if(this.options.copyFonts!==!1){let n=await this._copyFrameworkFonts(s,i);r.push(...n)}else this.logger.debug("Font copying disabled, skipping framework fonts");r.length>0&&this.logger.debug(`Added ${r.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return r}async _ensureAsset(e,r,s){let i=this.pathResolver.resolveAppPath(`${Ae.public}/${e}`);if(this.pathResolver.pathExists(i))return this.logger.debug(`Asset exists: ${e}`),!1;let n=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(n)){if(await this.pathResolver.copy(n,i))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _copyFrameworkFonts(e,r){let s=[],i=this.pathResolver.normalizePath(`${e}/fonts`);if(!this.pathResolver.pathExists(i))return this.logger.debug("Framework fonts directory not found, skipping fonts"),s;let n=this.pathResolver.resolveAppPath(`${Ae.public}/${Ae.fonts}`);this.pathResolver.pathExists(n)||(this.pathResolver.mkdir(n),this.logger.debug(`Created fonts directory: ${n}`));try{let a=await this.pathResolver.findFiles(i,"*",{onlyFiles:!0,ignore:["**/dist/**","**/build/**","**/.git/**"]});for(let o of a){let c=o.split("/").pop()||o.split("\\").pop(),u=this.pathResolver.resolveAppPath(`${Ae.public}/${Ae.fonts}/${c}`);if(this.pathResolver.pathExists(u)){this.logger.debug(`Font already exists: ${c}`);continue}await this.pathResolver.copy(o,u)?(s.push(`fonts/${c}`),this.logger.debug(`Copied framework font: ${c}`)):this.logger.debug(`Failed to copy font: ${c}`)}s.length>0&&this.logger.debug(`Copied ${s.length} font files from framework`)}catch(a){this.logger.debug(`Error copying fonts: ${a.message}`)}return s}async _processAssetFiles(e){let r=[];for(let s of e)try{let i=this.pathResolver.getFileInfo(s);if(i&&i.isFile){let n=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(n,i.size);a&&r.push(a)}}catch(i){this.logger.debug(`Error processing asset file ${s}: ${i.message}`)}return this.logger.debug(`Processed ${r.length} assets from ${e.length} files`),r}_analyzeAsset(e,r){let s=this._determineAssetType(e),i=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:i,size:r,sizeFormatted:this._formatBytes(r),isModern:this.options.modernFormats.includes(i)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let r=e.toLowerCase();if(r.includes("favicon"))return"favicon";if(r.includes("logo"))return"logo";if(r.includes("icon"))return"icon";if(r.includes("apple-touch"))return"apple-touch-icon";if(r.includes("android-chrome"))return"android-icon";if(r.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 r=1024,s=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(e)/Math.log(r));return parseFloat((e/Math.pow(r,i)).toFixed(2))+" "+s[i]}_matchesPattern(e,r){let s=e.toLowerCase(),i=r.toLowerCase();return s.includes(i.replace("*",""))}_buildAssetManifest(e){let r=e.map(i=>i.path);return{logo:{optimal:this._getOptimalAsset("logo",r,this.options.modernFormats),fallback:this._getOptimalAsset("logo",r,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",r,["svg","ico"]),fallback:this._getOptimalAsset("favicon",r,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",r,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",r,["png"]),512:this._getOptimalAsset("android-chrome-512x512",r,["png"])},manifest:r.find(i=>i.includes("manifest.json"))||null,modernFormats:e.filter(i=>i.isModern).map(i=>i.path),fallbackFormats:e.filter(i=>!i.isModern).map(i=>i.path)}}_getOptimalAsset(e,r,s){for(let i of s){let n=`/${e}.${i}`;if(r.includes(n))return n}return null}async _resolveFrameworkAssetsDir(e){try{let r=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",r);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let i=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(i)?(this.logger.debug(`Using framework assets from: ${i}`),i):(this.logger.debug(`Assets directory not found: ${i}`),null)}catch(r){return this.logger.debug(`Error resolving framework assets directory: ${r.message}`),null}}async _resolvePackage(e,r){try{let s=this.pathResolver.resolveFrameworkPackage(e,r);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,r){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),i=this.pathResolver.resolveAppPath(`${Ae.public}/${s}`);return this.pathResolver.pathExists(i)&&await this.pathResolver.read(i,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let r=await this._resolveFrameworkAssetsDir(e);if(!r)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${r}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let i=this.pathResolver.resolveAppPath(Ae.public);this.pathResolver.pathExists(i)||this.pathResolver.mkdir(i);let n=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,n)}catch(r){return this.logger.debug(`Failed to copy framework logo: ${r.message}`),!1}}async _generateMissingAssets(e){let r=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(r))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let i=[{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"}],n=[{name:"favicon.svg",format:"svg"}],a=[],o=[];try{let c=await this.pathResolver.read(r,{format:"text"});if(!c)return{generated:[],skipped:[...n,...i].map(f=>f.name),error:"Failed to read logo.svg"};for(let f of n){let m=`${s}/${f.name}`;if(this.pathResolver.pathExists(m)){o.push(f.name);continue}try{await this.pathResolver.write(`public/${f.name}`,c),a.push(f.name)}catch(v){this.logger.debug(`Failed to copy ${f.name}: ${v.message}`),o.push(f.name)}}let u=await Promise.resolve().then(()=>ya(Cn(),1)).catch(()=>null);if(!u)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),o.push(...i.map(f=>f.name));else for(let f of i){let m=`${s}/${f.name}`;if(this.pathResolver.pathExists(m)){o.push(f.name);continue}try{let v=u.default(c).resize(f.size,f.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),I;f.format==="ico"?I=await v.toFormat("png").toBuffer():I=await v.toFormat(f.format).toBuffer(),await this.pathResolver.write(`public/${f.name}`,I),a.push(f.name)}catch(v){this.logger.debug(`Failed to generate ${f.name}: ${v.message}`),o.push(f.name)}}return{generated:a,skipped:o,error:null}}catch(c){return this.logger.debug(`Asset generation failed: ${c.message}`),{generated:[],skipped:requiredAssets.map(u=>u.name),error:c.message}}}};var qr={data:null},Ur=class extends se{constructor(e={}){super(Yt,e)}getHandlerDefaults(){return{manifestPath:Xe.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 r=e.manifest?.logoSvgContent||null;return`// Auto-generated DnDev config by @donotdev/config
|
|
26
|
+
`}writeGeneratedFile(e,r,s="file"){let i=this.pathResolver.resolveAppPath(e);return this.pathResolver.writeSync(i,r),this.logger.debug(`Generated ${s}: ${i}`),i}async generateManifest(e){let r=this.createManifestContent(e);this.writeGeneratedFile(this.options.manifestPath,JSON.stringify(r,null,2),`${this.getHandlerName().toLowerCase()} manifest`)}async generateNextEnvTypes(){try{let e=this.pathResolver.resolveAppPath("next-env.d.ts"),r=this.pathResolver.readSync(e,{format:"text"});r&&(this.writeGeneratedFile("next-env.d.ts",r,"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,r){return e.plugins=e.plugins||[],e.plugins.push(new r.IgnorePlugin({resourceRegExp:/^vite$/})),e.plugins.push(new r.IgnorePlugin({resourceRegExp:/^@vitejs\//})),e.plugins.push(new r.IgnorePlugin({resourceRegExp:/vite/,contextRegExp:/node_modules/})),e}mergeRewrites(e,r){let s={beforeFiles:r?.beforeFiles||[],afterFiles:r?.afterFiles||[],fallback:r?.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")}};Q();g();g();var he=class t{constructor(e,r={}){if(this.constructor===t)throw new Error("BaseDiscovery is abstract and cannot be instantiated directly");this.pathResolver=e,this.options={...r},p.env.NODE_ENV==="development"&&(this.options.cacheTimeout=Math.max(this.options.cacheTimeout||6e4,3e5)),this.logger=me(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 r=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 i=await this._scanFiles(s),n=await this._processFiles(i);this.cache={...n,timestamp:Date.now()};let a=Date.now()-r;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 r=this._getPatternType();return await this.pathResolver.resolveFiles(e,r)}_extractFileNameInfo(e){let r=e.split("/"),s=r[r.length-1],i=s.split(".")[0],n=s.split(".").pop();return{fileName:s,baseName:i,extension:n,directory:r.slice(0,-1).join("/")}}async _processSingleFile(e,r){try{let s=this.pathResolver.getFileInfo(e);return s?await r(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,r){return(await Promise.all(e.map(i=>this._processSingleFile(i,r)))).filter(i=>i!==null)}_isCacheValid(){return this.cache?Date.now()-this.cache.timestamp<this.options.cacheTimeout:!1}};Q();var Yt=class extends he{constructor(e,r={}){super(e,{assets:ce.assets.fallback,assetPatterns:ce.assets.patterns,frameworkPackage:lr.package,assetsPath:lr.assetsPath,modernFormats:ce.assets.modern,...r}),this.hasRunForSession=!1}_getDiscoveryType(){return"Asset"}async _getPatterns(){return await this.pathResolver.resolvePatterns("assets")}_getPatternType(){return"assets"}async _processFiles(e){let r=this.pathResolver.getAppRoot(),s=await this._ensureDefaultAssets(r),i=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(i)||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=[],o=this.pathResolver.resolveAppPath("public/logo.svg");this.pathResolver.pathExists(o)&&this.options.generateAssets!==!1&&(a=(await this._generateMissingAssets(r))?.generated||[]);let{consumerFiles:c}=e,u=await this._processAssetFiles(c),f=this._buildAssetManifest(u),m=await this._readLogoSvgContent("/logo.svg",r);return{assets:u,manifest:{...f,logoSvgContent:m},copiedAssets:s,generatedAssets:a,pwaIcons:this._extractPWAIcons(u)}}_extractPWAIcons(e){let r=[/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 i=s.path.split("/").pop()||"";return r.some(n=>n.test(i))}).map(s=>{let i=s.path.split("/").pop()||"",n=i.match(/(\d+)x(\d+)/),a=n?{width:parseInt(n[1]),height:parseInt(n[2])}:this._getDefaultIconSize(i);return{type:"icon",path:s.path.replace(/^\/?public\//,""),size:a,format:s.format||this._getFormatFromPath(s.path),purpose:this._getIconPurpose(i)}})}_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,r=this.cache?.copiedAssets?.length||0,s=this.cache?.copiedAssets?.filter(i=>i.startsWith("fonts/")).length||0;return s>0?`${e} assets, ${r} copied (${s} fonts)`:`${e} assets, ${r} copied`}async discoverAssets(e=!1){return await this.discover(e)}getAssets(){return this.cache?.assets||[]}getManifest(){return this.cache?.manifest||this._getEmptyManifest()}getOptimalAsset(e,r){let s=this.getAssets().map(n=>n.path),i=r||this.options.modernFormats;for(let n of i){let a=`/${e}.${n}`;if(s.includes(a))return a}return null}async _ensureDefaultAssets(e){this.logger.debug("Ensuring default assets with modern format support...");let r=[];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"),r;let i=this.pathResolver.resolveAppPath(Ae.public);this.pathResolver.pathExists(i)||(this.pathResolver.mkdir(i),this.logger.debug(`Created public directory: ${i}`));for(let n of this.options.assets)await this._ensureAsset(n,i,s)&&r.push(n);if(this.options.copyFonts!==!1){let n=await this._copyFrameworkFonts(s,i);r.push(...n)}else this.logger.debug("Font copying disabled, skipping framework fonts");r.length>0&&this.logger.debug(`Added ${r.length} default assets from DNDev framework`)}catch(s){this.logger.debug(`Failed to ensure default assets: ${s.message}`)}return r}async _ensureAsset(e,r,s){let i=this.pathResolver.resolveAppPath(`${Ae.public}/${e}`);if(this.pathResolver.pathExists(i))return this.logger.debug(`Asset exists: ${e}`),!1;let n=this.pathResolver.normalizePath(`${s}/${e}`);if(this.pathResolver.pathExists(n)){if(await this.pathResolver.copy(n,i))return this.logger.debug(`Copied framework asset: ${e}`),!0;this.logger.debug(`Failed to copy framework asset: ${e}`)}return!1}async _copyFrameworkFonts(e,r){let s=[],i=this.pathResolver.normalizePath(`${e}/fonts`);if(!this.pathResolver.pathExists(i))return this.logger.debug("Framework fonts directory not found, skipping fonts"),s;let n=this.pathResolver.resolveAppPath(`${Ae.public}/${Ae.fonts}`);this.pathResolver.pathExists(n)||(this.pathResolver.mkdir(n),this.logger.debug(`Created fonts directory: ${n}`));try{let a=await this.pathResolver.findFiles(i,"*",{onlyFiles:!0,ignore:["**/dist/**","**/build/**","**/.git/**"]});for(let o of a){let c=o.split("/").pop()||o.split("\\").pop(),u=this.pathResolver.resolveAppPath(`${Ae.public}/${Ae.fonts}/${c}`);if(this.pathResolver.pathExists(u)){this.logger.debug(`Font already exists: ${c}`);continue}await this.pathResolver.copy(o,u)?(s.push(`fonts/${c}`),this.logger.debug(`Copied framework font: ${c}`)):this.logger.debug(`Failed to copy font: ${c}`)}s.length>0&&this.logger.debug(`Copied ${s.length} font files from framework`)}catch(a){this.logger.debug(`Error copying fonts: ${a.message}`)}return s}async _processAssetFiles(e){let r=[];for(let s of e)try{let i=this.pathResolver.getFileInfo(s);if(i&&i.isFile){let n=s.split("/").pop()||s.split("\\").pop(),a=this._analyzeAsset(n,i.size);a&&r.push(a)}}catch(i){this.logger.debug(`Error processing asset file ${s}: ${i.message}`)}return this.logger.debug(`Processed ${r.length} assets from ${e.length} files`),r}_analyzeAsset(e,r){let s=this._determineAssetType(e),i=this._determineAssetFormat(e);return this.options.assetPatterns.some(a=>this._matchesPattern(e,a))?{path:`/${e}`,name:e,type:s,format:i,size:r,sizeFormatted:this._formatBytes(r),isModern:this.options.modernFormats.includes(i)}:(this.logger.debug(`Asset ${e} does not match any pattern, skipping`),null)}_determineAssetType(e){let r=e.toLowerCase();if(r.includes("favicon"))return"favicon";if(r.includes("logo"))return"logo";if(r.includes("icon"))return"icon";if(r.includes("apple-touch"))return"apple-touch-icon";if(r.includes("android-chrome"))return"android-icon";if(r.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 r=1024,s=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(e)/Math.log(r));return parseFloat((e/Math.pow(r,i)).toFixed(2))+" "+s[i]}_matchesPattern(e,r){let s=e.toLowerCase(),i=r.toLowerCase();return s.includes(i.replace("*",""))}_buildAssetManifest(e){let r=e.map(i=>i.path);return{logo:{optimal:this._getOptimalAsset("logo",r,this.options.modernFormats),fallback:this._getOptimalAsset("logo",r,["png","jpg","jpeg"])},favicon:{optimal:this._getOptimalAsset("favicon",r,["svg","ico"]),fallback:this._getOptimalAsset("favicon",r,["ico"])},appleTouchIcon:this._getOptimalAsset("apple-touch-icon",r,["png"]),androidChrome:{192:this._getOptimalAsset("android-chrome-192x192",r,["png"]),512:this._getOptimalAsset("android-chrome-512x512",r,["png"])},manifest:r.find(i=>i.includes("manifest.json"))||null,modernFormats:e.filter(i=>i.isModern).map(i=>i.path),fallbackFormats:e.filter(i=>!i.isModern).map(i=>i.path)}}_getOptimalAsset(e,r,s){for(let i of s){let n=`/${e}.${i}`;if(r.includes(n))return n}return null}async _resolveFrameworkAssetsDir(e){try{let r=this.pathResolver.getRepoRoot(),s=await this._resolvePackage("@donotdev/ui",r);if(!s)return this.logger.debug("@donotdev/ui package not found"),null;let i=this.pathResolver.normalizePath(`${s}/assets`);return this.pathResolver.pathExists(i)?(this.logger.debug(`Using framework assets from: ${i}`),i):(this.logger.debug(`Assets directory not found: ${i}`),null)}catch(r){return this.logger.debug(`Error resolving framework assets directory: ${r.message}`),null}}async _resolvePackage(e,r){try{let s=this.pathResolver.resolveFrameworkPackage(e,r);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,r){if(!e||!e.endsWith(".svg"))return null;try{let s=e.slice(1),i=this.pathResolver.resolveAppPath(`${Ae.public}/${s}`);return this.pathResolver.pathExists(i)&&await this.pathResolver.read(i,{format:"text"})||null}catch(s){return this.logger.debug(`Failed to read logo SVG content: ${s.message}`),null}}async _copyFrameworkLogo(e){try{let r=await this._resolveFrameworkAssetsDir(e);if(!r)return this.logger.debug("Framework assets directory not found"),!1;let s=this.pathResolver.normalizePath(`${r}/logo.svg`);if(!this.pathResolver.pathExists(s))return this.logger.debug("Framework logo.svg not found"),!1;let i=this.pathResolver.resolveAppPath(Ae.public);this.pathResolver.pathExists(i)||this.pathResolver.mkdir(i);let n=this.pathResolver.resolveAppPath("public/logo.svg");return await this.pathResolver.copy(s,n)}catch(r){return this.logger.debug(`Failed to copy framework logo: ${r.message}`),!1}}async _generateMissingAssets(e){let r=this.pathResolver.resolveAppPath("public/logo.svg"),s=this.pathResolver.resolveAppPath("public");if(!this.pathResolver.pathExists(r))return this.logger.debug("logo.svg not found in public/, skipping asset generation"),{generated:[],skipped:[],error:"logo.svg not found in public/"};let i=[{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"}],n=[{name:"favicon.svg",format:"svg"}],a=[],o=[];try{let c=await this.pathResolver.read(r,{format:"text"});if(!c)return{generated:[],skipped:[...n,...i].map(f=>f.name),error:"Failed to read logo.svg"};for(let f of n){let m=`${s}/${f.name}`;if(this.pathResolver.pathExists(m)){o.push(f.name);continue}try{await this.pathResolver.write(`public/${f.name}`,c),a.push(f.name)}catch(v){this.logger.debug(`Failed to copy ${f.name}: ${v.message}`),o.push(f.name)}}let u=await Promise.resolve().then(()=>ya(Cn(),1)).catch(()=>null);if(!u)this.logger.debug("sharp not installed, skipping PNG/ICO generation"),o.push(...i.map(f=>f.name));else for(let f of i){let m=`${s}/${f.name}`;if(this.pathResolver.pathExists(m)){o.push(f.name);continue}try{let v=u.default(r).resize(f.size,f.size,{fit:"contain",background:{r:255,g:255,b:255,alpha:0}}),I;f.format==="ico"?I=await v.toFormat("png").toBuffer():I=await v.toFormat(f.format).toBuffer(),await this.pathResolver.write(`public/${f.name}`,I),a.push(f.name)}catch(v){this.logger.debug(`Failed to generate ${f.name}: ${v.message}`),o.push(f.name)}}return{generated:a,skipped:o,error:null}}catch(c){return this.logger.debug(`Asset generation failed: ${c.message}`),{generated:[],skipped:requiredAssets.map(u=>u.name),error:c.message}}}};var qr={data:null},Ur=class extends se{constructor(e={}){super(Yt,e)}getHandlerDefaults(){return{manifestPath:Xe.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 r=e.manifest?.logoSvgContent||null;return`// Auto-generated DnDev config by @donotdev/config
|
|
27
27
|
// Generated at: ${new Date().toISOString()}
|
|
28
28
|
// Populates _DNDEV_CONFIG_ with discovery results
|
|
29
29
|
|
|
@@ -551,7 +551,7 @@ export function useTheme() {
|
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
export default useTheme;
|
|
554
|
-
`}};function Hn(t={}){return new Xr(t)}function Wn({debug:t,verbose:e,generateManifest:r,routeOptions:s,themeOptions:i,i18nOptions:n,assetOptions:a,seoOptions:o,pwaOptions:c,serverShimOptions:u,appUrl:f,isDev:m,logger:v}){let I=s.debug??t,L=i.debug??t,B=n.debug??t,oe=a.debug??t,Be=o.debug??t,fe=c.debug??t,Re=u.debug??t,Ue=s.verbose??e,le=i.verbose??e,$e=n.verbose??e,gt=a.verbose??e,qe=o.verbose??e,M=c.verbose??e,Ge=u.verbose??e,D={debug:t,verbose:e,generateManifest:r},He=s.disabled?null:Un({...D,...s,debug:I,verbose:Ue});t&&v.debug(`Route handler created: ${He?"enabled":"disabled"} (debug: ${I})`);let De=Hn({...D,...i,debug:L,verbose:le}),O=Dn({...D,...n,debug:B,verbose:$e}),U=jn({...D,...a,debug:oe,verbose:gt}),z=qn({...D,...o,debug:Be,verbose:qe,appUrl:f,isDev:m}),Y=Tn({...D,...c,debug:fe,verbose:M}),pt=Gn({...D,...u,debug:Re,verbose:Ge});return{routeHandler:He,themeHandler:De,i18nHandler:O,assetHandler:U,seoHandler:z,pwaHandler:Y,serverShimHandler:pt}}function Vn(t,e){let r={};if(t.routeHandler)try{r.routeConfig=t.routeHandler.createNextConfig()}catch(i){e.error(`Route handler failed during config creation: ${i.message}`),e.error(`Stack: ${i.stack||"No stack trace available"}`),r.routeConfig=()=>({})}else r.routeConfig=()=>({});let s=[{name:"theme",handler:t.themeHandler},{name:"i18n",handler:t.i18nHandler},{name:"asset",handler:t.assetHandler},{name:"seo",handler:t.seoHandler},{name:"pwa",handler:t.pwaHandler}];for(let{name:i,handler:n}of s)try{r[`${i}Config`]=n.createNextConfig()}catch(a){e.error(`${i.charAt(0).toUpperCase()+i.slice(1)} handler failed: ${a.message}`),e.error(`Stack: ${a.stack||"No stack trace available"}`),r[`${i}Config`]=()=>({})}try{r.serverShimConfig=t.serverShimHandler}catch(i){e.error(`ServerShim handler failed: ${i.message}`),e.error(`Stack: ${i.stack||"No stack trace available"}`),r.serverShimConfig=()=>({})}return r}g();var lu=["public/route-manifest.json","public/theme-manifest.json","public/i18n-manifest.json","public/asset-manifest.json","public/seo-manifest.json","public/pwa-manifest.json"],cu="dndev-config-",Xn=".dndev-build";function hu(t){if(!t)return!1;let e=V.getInstance(),r=e.resolveAppPath(Xn),s=p.env.DNDEV_BUILD_ID;try{return(e.readSync(r,{format:"text"})||"").trim()===s}catch{return!1}}function uu(t){if(!t)return;let e=V.getInstance(),r=e.resolveAppPath(Xn),s=p.env.DNDEV_BUILD_ID;try{e.writeSync(r,s)}catch{}}function Jr(t,e){if(!t)return;let r=V.getInstance();for(let i of lu){let n=r.resolveAppPath(i);if(r.pathExists(n))try{r.removeSync(n),e.debug(`Cleaned: ${i}`)}catch{}}let s=r.resolveAppPath("src/config");if(r.pathExists(s))try{let i=r.readdirSync(s);for(let n of i)if(n.startsWith(cu)&&n.endsWith(".js"))try{let a=r.resolvePath(n,s);r.removeSync(a),e.debug(`Cleaned: src/config/${n}`)}catch{}}catch{}}async function Kr({routeHandler:t,themeHandler:e,i18nHandler:r,assetHandler:s,seoHandler:i,pwaHandler:n},a){let o=t?.pathResolver;if(!o)throw new Error("PathResolver not available - handlers must be initialized with PathResolver");let c=o.getAppRoot(),u=o.getRepoRoot();if(!c||c===u){a.warn("\u26A0\uFE0F App root not properly set before discovery - waiting for appRoot resolution"),await new Promise(L=>setTimeout(L,0));let I=o.getAppRoot();if(!I||I===u)throw new Error("App root not set before discovery. Ensure resolveAppRoot() is called before runDiscoveries().")}if(hu(c)){a.debug("Discoveries already completed this build, skipping");return}let f=Date.now();if(t)try{a.info("\u{1F50D} Starting route discovery...");let L=(await t.generateFiles())?.routes?.length||0;a.info(`\u2705 Routes generated: ${L} routes found`),L===0&&a.error("\u274C NO ROUTES FOUND! Check that pages exist in src/pages/")}catch(I){throw a.error(`\u274C Route generation failed: ${I.message}`),I.stack&&a.error(`Stack: ${I.stack}`),I}else a.warn("\u26A0\uFE0F Route handler is disabled - no routes will be discovered");let m=[{name:"Theme",handler:e},{name:"I18n",handler:r},{name:"Asset",handler:s},{name:"SEO",handler:i},{name:"PWA",handler:n}];for(let{name:I,handler:L}of m)try{await L.generateFiles()}catch(B){a.debug(`${I} generation failed: ${B.message}`)}let v=Date.now()-f;a.verbose?.(`\u2705 All discoveries completed in ${v}ms - Next.js can now compile`),uu(c)}async function Jn(t,e,r){if(r)return!1;try{let s=await t.getDiscoveryData();return s?.copiedAssets?.length>0&&e.info(`\u{1F4E6} Copied ${s.copiedAssets.length} assets from framework`),!0}catch(s){return e.debug(`Asset discovery failed (non-critical): ${s.message}`),!1}}g();function Kn({originalWebpack:t,unusedFeaturePackages:e,usedFeaturePackages:r,logger:s,debug:i}){return(n,a)=>{let{dev:o,isServer:c,webpack:u}=a;o&&!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 f=n.module?.rules?.find(m=>m.test?.test?.(".svg"));if(f&&(f.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]"}}),u?.IgnorePlugin&&n.plugins.push(new u.IgnorePlugin({resourceRegExp:/^(vite|@vitejs|vite-tsconfig-paths|react-router-dom)$/})),e.length>0)if(s.info(`\u{1F6AB} Excluding unused features: ${e.join(", ")}`),s.info(`\u2705 Including features: ${r.join(", ")}`),n.externals=n.externals||[],Array.isArray(n.externals))n.externals.push(...e);else{let m=n.externals;n.externals=(v,I,L)=>e.includes(I)?L(null,"commonjs "+I):typeof m=="function"?m(v,I,L):L()}return t?t(n,a):n}}function Yn({originalRewrites:t,handlers:e,logger:r}){return async function(){try{let s=t?await t():[],n=e.filter(a=>a?.getAPIRewrites).map(a=>a.getAPIRewrites()).reduce((a,o)=>(o?.beforeFiles&&a.beforeFiles.push(...o.beforeFiles),o?.afterFiles&&a.afterFiles.push(...o.afterFiles),o?.fallback&&a.fallback.push(...o.fallback),a),{beforeFiles:[],afterFiles:[],fallback:[]});return{beforeFiles:[...Array.isArray(s)?[]:s?.beforeFiles||[],...n.beforeFiles],afterFiles:[...Array.isArray(s)?s:s?.afterFiles||[],...n.afterFiles],fallback:[...Array.isArray(s)?[]:s?.fallback||[],...n.fallback]}}catch(s){return r.error(`Next.js config failed to merge rewrites: ${s.message}`),r.error(`Stack: ${s.stack||"No stack trace available"}`),{beforeFiles:[],afterFiles:[],fallback:[]}}}}function Qn({routeResult:t,themeResult:e,i18nResult:r,assetResult:s,seoResult:i,pwaResult:n,serverShimResult:a,restNextConfig:o,discoveredPackages:c,nextVersion:u,isNext15:f,webpackConfig:m,rewritesConfig:v,missingOptionalDeps:I,env:L,logger:B}){let oe=o?.output==="export";return{transpilePackages:c,...Ne(o)?o:(B.warn("restNextConfig is not a plain object:",o),{}),...p.env.NODE_ENV==="development"&&{devIndicators:{position:"bottom-right"},onDemandEntries:{maxInactiveAge:25*1e3,pagesBufferLength:2},experimental:{...o.experimental}},...Ne(t)?t:(B.error(`Route handler config invalid (got ${typeof t}):`,t),{}),...Ne(e)?e:(B.error(`Theme handler config invalid (got ${typeof e}):`,e),{}),...Ne(r)?r:(B.error(`I18n handler config invalid (got ${typeof r}):`,r),{}),...Ne(s)?s:(B.error(`Asset handler config invalid (got ${typeof s}):`,s),{}),...Ne(i)?i:(B.error(`SEO handler config invalid (got ${typeof i}):`,i),{}),...Ne(n)?n:(B.error(`PWA handler config invalid (got ${typeof n}):`,n),{}),...Ne(a)?a:(B.warn("serverShimConfig returned non-object:",a),{}),webpack:m,...oe?{}:{rewrites:v},env:L,...f&&o.experimental&&{experimental:o.experimental},...p.env.NODE_ENV==="production"&&{logging:{fetches:{fullUrl:!1}}},turbopack:{resolveAlias:{...(I||[]).reduce((fe,Re)=>(fe[Re]="./empty.js",fe),{}),...o.turbopack?.resolveAlias||{}},...o.turbopack||{}}}}function fu(t={}){let{port:e,...r}=t;if(e&&p.env.NODE_ENV!=="production"&&(p.env.PORT=String(e)),!p.env.DNDEV_BUILD_ID){let Se=p.env.CI==="true";p.env.DNDEV_BUILD_ID=Se?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9)}let{appConfig:s,...i}=r;if(!s)throw new Error("appConfig is required. Import appConfig from src/config/app.ts and pass it to defineNextConfig({ appConfig, ... })");let n=s?.features?{debug:s.features.debug}:void 0,a=s?.seo&&typeof s.seo!="boolean"?{...s.seo,siteName:s.seo.siteName||s.app?.name}:s?.app?.name?{siteName:s.app.name}:void 0,o=s?.app?{name:s.app.name,shortName:s.app.shortName,description:s.app.description,url:s.app.url}:void 0,{features:c,seo:u,...f}=i,m={...n?{features:n}:{},...a?{seo:a}:{},...f},v=ns(m),I=as(v);if(!I)throw new Error("normalizeOptions returned undefined");let{generateManifest:L,debug:B,verbose:oe,mode:Be,isDev:fe,routeOptions:Re,themeOptions:Ue,i18nOptions:le,assetOptions:$e,pwaOptions:gt,seoOptions:qe,serverShimOptions:M,nextConfigOptions:Ge}=I,D=me("next-config",B,oe),{appRoot:He,appRootSet:De}=ds({logger:D,debug:B}),O=!1,U=!1,{installed:z}=ur(p.cwd()),Y=Object.values(ts.packageNames),pt=Y.filter(Se=>!z.includes(Se)),rr=Y.filter(Se=>z.includes(Se)),mt=p.env.DNDEV_BUILD_ID,sr=Re?.routingMode||"app";D.info(`
|
|
554
|
+
`}};function Hn(t={}){return new Xr(t)}function Wn({debug:t,verbose:e,generateManifest:r,routeOptions:s,themeOptions:i,i18nOptions:n,assetOptions:a,seoOptions:o,pwaOptions:c,serverShimOptions:u,appUrl:f,isDev:m,logger:v}){let I=s.debug??t,L=i.debug??t,B=n.debug??t,oe=a.debug??t,Be=o.debug??t,fe=c.debug??t,Re=u.debug??t,Ue=s.verbose??e,le=i.verbose??e,$e=n.verbose??e,gt=a.verbose??e,qe=o.verbose??e,M=c.verbose??e,Ge=u.verbose??e,D={debug:t,verbose:e,generateManifest:r},He=s.disabled?null:Un({...D,...s,debug:I,verbose:Ue});t&&v.debug(`Route handler created: ${He?"enabled":"disabled"} (debug: ${I})`);let De=Hn({...D,...i,debug:L,verbose:le}),O=Dn({...D,...n,debug:B,verbose:$e}),U=jn({...D,...a,debug:oe,verbose:gt}),z=qn({...D,...o,debug:Be,verbose:qe,appUrl:f,isDev:m}),Y=Tn({...D,...c,debug:fe,verbose:M}),pt=Gn({...D,...u,debug:Re,verbose:Ge});return{routeHandler:He,themeHandler:De,i18nHandler:O,assetHandler:U,seoHandler:z,pwaHandler:Y,serverShimHandler:pt}}function Vn(t,e){let r={};if(t.routeHandler)try{r.routeConfig=t.routeHandler.createNextConfig()}catch(i){e.error(`Route handler failed during config creation: ${i.message}`),e.error(`Stack: ${i.stack||"No stack trace available"}`),r.routeConfig=()=>({})}else r.routeConfig=()=>({});let s=[{name:"theme",handler:t.themeHandler},{name:"i18n",handler:t.i18nHandler},{name:"asset",handler:t.assetHandler},{name:"seo",handler:t.seoHandler},{name:"pwa",handler:t.pwaHandler}];for(let{name:i,handler:n}of s)try{r[`${i}Config`]=n.createNextConfig()}catch(a){e.error(`${i.charAt(0).toUpperCase()+i.slice(1)} handler failed: ${a.message}`),e.error(`Stack: ${a.stack||"No stack trace available"}`),r[`${i}Config`]=()=>({})}try{r.serverShimConfig=t.serverShimHandler}catch(i){e.error(`ServerShim handler failed: ${i.message}`),e.error(`Stack: ${i.stack||"No stack trace available"}`),r.serverShimConfig=()=>({})}return r}g();var lu=["public/route-manifest.json","public/theme-manifest.json","public/i18n-manifest.json","public/asset-manifest.json","public/seo-manifest.json","public/pwa-manifest.json"],cu="dndev-config-",Xn=".dndev-build";function hu(t){if(!t)return!1;let e=V.getInstance(),r=e.resolveAppPath(Xn),s=p.env.DNDEV_BUILD_ID;try{return(e.readSync(r,{format:"text"})||"").trim()===s}catch{return!1}}function uu(t){if(!t)return;let e=V.getInstance(),r=e.resolveAppPath(Xn),s=p.env.DNDEV_BUILD_ID;try{e.writeSync(r,s)}catch{}}function Jr(t,e){if(!t)return;let r=V.getInstance();for(let i of lu){let n=r.resolveAppPath(i);if(r.pathExists(n))try{r.removeSync(n),e.debug(`Cleaned: ${i}`)}catch{}}let s=r.resolveAppPath("src/config");if(r.pathExists(s))try{let i=r.readdirSync(s);for(let n of i)if(n.startsWith(cu)&&n.endsWith(".js"))try{let a=r.resolvePath(n,s);r.removeSync(a),e.debug(`Cleaned: src/config/${n}`)}catch{}}catch{}}async function Kr({routeHandler:t,themeHandler:e,i18nHandler:r,assetHandler:s,seoHandler:i,pwaHandler:n},a){let o=t?.pathResolver;if(!o)throw new Error("PathResolver not available - handlers must be initialized with PathResolver");let c=o.getAppRoot(),u=o.getRepoRoot();if(!c||c===u){a.warn("\u26A0\uFE0F App root not properly set before discovery - waiting for appRoot resolution"),await new Promise(L=>setTimeout(L,0));let I=o.getAppRoot();if(!I||I===u)throw new Error("App root not set before discovery. Ensure resolveAppRoot() is called before runDiscoveries().")}if(hu(c)){a.debug("Discoveries already completed this build, skipping");return}let f=Date.now();if(t)try{a.info("\u{1F50D} Starting route discovery...");let L=(await t.generateFiles())?.routes?.length||0;a.info(`\u2705 Routes generated: ${L} routes found`),L===0&&a.error("\u274C NO ROUTES FOUND! Check that pages exist in src/pages/")}catch(I){throw a.error(`\u274C Route generation failed: ${I.message}`),I.stack&&a.error(`Stack: ${I.stack}`),I}else a.warn("\u26A0\uFE0F Route handler is disabled - no routes will be discovered");let m=[{name:"Theme",handler:e},{name:"I18n",handler:r},{name:"Asset",handler:s},{name:"SEO",handler:i},{name:"PWA",handler:n}];for(let{name:I,handler:L}of m)try{await L.generateFiles()}catch(B){a.debug(`${I} generation failed: ${B.message}`)}let v=Date.now()-f;a.verbose?.(`\u2705 All discoveries completed in ${v}ms - Next.js can now compile`),uu(c)}async function Jn(t,e,r){if(r)return!1;try{let s=await t.getDiscoveryData();return s?.copiedAssets?.length>0&&e.info(`\u{1F4E6} Copied ${s.copiedAssets.length} assets from framework`),!0}catch(s){return e.debug(`Asset discovery failed (non-critical): ${s.message}`),!1}}g();function Kn({originalWebpack:t,unusedFeaturePackages:e,usedFeaturePackages:r,logger:s,debug:i}){return(n,a)=>{let{dev:o,isServer:c,webpack:u}=a;o&&!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 f=n.module?.rules?.find(m=>m.test?.test?.(".svg"));if(f&&(f.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]"}}),u?.IgnorePlugin&&n.plugins.push(new u.IgnorePlugin({resourceRegExp:/^(vite|@vitejs|vite-tsconfig-paths|react-router-dom)$/})),e.length>0)if(s.info(`\u{1F6AB} Excluding unused features: ${e.join(", ")}`),s.info(`\u2705 Including features: ${r.join(", ")}`),n.externals=n.externals||[],Array.isArray(n.externals))n.externals.push(...e);else{let m=n.externals;n.externals=(v,I,L)=>e.includes(I)?L(null,"commonjs "+I):typeof m=="function"?m(v,I,L):L()}return t?t(n,a):n}}function Yn({originalRewrites:t,handlers:e,logger:r}){return async function(){try{let s=t?await t():[],n=e.filter(a=>a?.getAPIRewrites).map(a=>a.getAPIRewrites()).reduce((a,o)=>(o?.beforeFiles&&a.beforeFiles.push(...o.beforeFiles),o?.afterFiles&&a.afterFiles.push(...o.afterFiles),o?.fallback&&a.fallback.push(...o.fallback),a),{beforeFiles:[],afterFiles:[],fallback:[]});return{beforeFiles:[...Array.isArray(s)?[]:s?.beforeFiles||[],...n.beforeFiles],afterFiles:[...Array.isArray(s)?s:s?.afterFiles||[],...n.afterFiles],fallback:[...Array.isArray(s)?[]:s?.fallback||[],...n.fallback]}}catch(s){return r.error(`Next.js config failed to merge rewrites: ${s.message}`),r.error(`Stack: ${s.stack||"No stack trace available"}`),{beforeFiles:[],afterFiles:[],fallback:[]}}}}function Qn({routeResult:t,themeResult:e,i18nResult:r,assetResult:s,seoResult:i,pwaResult:n,serverShimResult:a,restNextConfig:o,discoveredPackages:c,nextVersion:u,isNext15:f,webpackConfig:m,rewritesConfig:v,missingOptionalDeps:I,env:L,logger:B}){let oe=o?.output==="export";return{transpilePackages:c,...f?{serverExternalPackages:[...new Set([...c,...o?.serverExternalPackages||o?.serverComponentsExternalPackages||[]])]}:{serverComponentsExternalPackages:[...new Set([...c,...o?.serverComponentsExternalPackages||[]])]},...Ne(o)?o:(B.warn("restNextConfig is not a plain object:",o),{}),...p.env.NODE_ENV==="development"&&{devIndicators:{position:"bottom-right"},onDemandEntries:{maxInactiveAge:25*1e3,pagesBufferLength:2},experimental:{...o.experimental}},...Ne(t)?t:(B.error(`Route handler config invalid (got ${typeof t}):`,t),{}),...Ne(e)?e:(B.error(`Theme handler config invalid (got ${typeof e}):`,e),{}),...Ne(r)?r:(B.error(`I18n handler config invalid (got ${typeof r}):`,r),{}),...Ne(s)?s:(B.error(`Asset handler config invalid (got ${typeof s}):`,s),{}),...Ne(i)?i:(B.error(`SEO handler config invalid (got ${typeof i}):`,i),{}),...Ne(n)?n:(B.error(`PWA handler config invalid (got ${typeof n}):`,n),{}),...Ne(a)?a:(B.warn("serverShimConfig returned non-object:",a),{}),webpack:m,...oe?{}:{rewrites:v},env:L,...f&&o.experimental&&{experimental:o.experimental},...p.env.NODE_ENV==="production"&&{logging:{fetches:{fullUrl:!1}}},turbopack:{resolveAlias:{...(I||[]).reduce((fe,Re)=>(fe[Re]="./empty.js",fe),{}),...o.turbopack?.resolveAlias||{}},...o.turbopack||{}}}}function fu(t={}){let{port:e,...r}=t;if(e&&p.env.NODE_ENV!=="production"&&(p.env.PORT=String(e)),!p.env.DNDEV_BUILD_ID){let Se=p.env.CI==="true";p.env.DNDEV_BUILD_ID=Se?`ci-${Math.random().toString(36).slice(2,9)}`:Math.random().toString(36).slice(2,9)}let{appConfig:s,...i}=r;if(!s)throw new Error("appConfig is required. Import appConfig from src/config/app.ts and pass it to defineNextConfig({ appConfig, ... })");let n=s?.features?{debug:s.features.debug}:void 0,a=s?.seo&&typeof s.seo!="boolean"?{...s.seo,siteName:s.seo.siteName||s.app?.name}:s?.app?.name?{siteName:s.app.name}:void 0,o=s?.app?{name:s.app.name,shortName:s.app.shortName,description:s.app.description,url:s.app.url}:void 0,{features:c,seo:u,...f}=i,m={...n?{features:n}:{},...a?{seo:a}:{},...f},v=ns(m),I=as(v);if(!I)throw new Error("normalizeOptions returned undefined");let{generateManifest:L,debug:B,verbose:oe,mode:Be,isDev:fe,routeOptions:Re,themeOptions:Ue,i18nOptions:le,assetOptions:$e,pwaOptions:gt,seoOptions:qe,serverShimOptions:M,nextConfigOptions:Ge}=I,D=me("next-config",B,oe),{appRoot:He,appRootSet:De}=ds({logger:D,debug:B}),O=!1,U=!1,{installed:z}=ur(p.cwd()),Y=Object.values(ts.packageNames),pt=Y.filter(Se=>!z.includes(Se)),rr=Y.filter(Se=>z.includes(Se)),mt=p.env.DNDEV_BUILD_ID,sr=Re?.routingMode||"app";D.info(`
|
|
555
555
|
\u{1F3D7}\uFE0F DnDev Framework - Building for ${Be}${mt?` [build:${mt}]`:""}`),D.info(` Platform: Next.js | Routing: ${sr}
|
|
556
556
|
`);let St=o?.url;if(fe){let Se=p.env.PORT||3e3;p.env.NEXT_PUBLIC_APP_URL=`http://localhost:${Se}`,B&&(D.debug(`NEXT_PUBLIC_APP_URL: ${p.env.NEXT_PUBLIC_APP_URL}`),e&&D.debug(`Port configured: ${Se} (set PORT env var)`))}else St?(p.env.NEXT_PUBLIC_APP_URL=St,B&&D.debug(`NEXT_PUBLIC_APP_URL: ${St}`)):D.warn("NEXT_PUBLIC_APP_URL not found in appConfig.app.url");let ke=Wn({debug:B,verbose:oe,generateManifest:L,routeOptions:Re,themeOptions:Ue,i18nOptions:le,assetOptions:$e,seoOptions:qe,pwaOptions:gt,serverShimOptions:M,appUrl:St,isDev:fe,logger:D}),We=Vn(ke,D);return async function(ir={}){let nr=!1,At="15.0.0";try{At=await fr(),nr=await us(),B&&D.debug(`Next.js version: ${At} (15+: ${nr})`)}catch(vt){B&&D.warn("Could not determine Next.js version:",vt.message)}let bt=V.getInstance(),_t=De?fs():[];B&&_t.length>0&&D.debug(`Discovered ${_t.length} packages: ${_t.join(", ")}`);let{missing:ar}=ur(bt.getAppRoot());B&&ar.length>0&&D.debug(`Missing optional deps (will alias to empty): ${ar.join(", ")}`);let Yr=bt.getAppRoot();if(De&&!O){let vt=bt.resolveAppPath(".dndev-build"),or=p.env.DNDEV_BUILD_ID;try{bt.readSync(vt,{format:"text"})?.trim()===or?(D.debug("Discoveries already completed by another worker, skipping"),O=!0):(Jr(Yr,D),await Kr(ke,D),O=!0)}catch{Jr(Yr,D),await Kr(ke,D),O=!0}}let Ve=typeof ir=="object"&&ir!==null?ir:{},{webpack:ea,rewrites:ta,...ra}=Ve;De&&!U&&(U=await Jn(ke.assetHandler,D,U));let sa=We.routeConfig(Ve),ia=We.themeConfig(Ve),na=We.i18nConfig(Ve),aa=We.assetConfig(Ve),oa=We.seoConfig(Ve),la=We.pwaConfig(Ve),ca=We.serverShimConfig(),ha=Kn({originalWebpack:ea,unusedFeaturePackages:pt,usedFeaturePackages:rr,logger:D,debug:B}),ua=Yn({originalRewrites:ta,handlers:[ke.routeHandler,ke.themeHandler,ke.i18nHandler,ke.assetHandler,ke.pwaHandler],logger:D}),fa={_DNDEV_CONFIG_:JSON.stringify({platform:"nextjs",mode:p.env.NODE_ENV||"development",version:At,context:"build",timestamp:Date.now()}),...p.env.NEXT_PUBLIC_APP_URL?{NEXT_PUBLIC_APP_URL:p.env.NEXT_PUBLIC_APP_URL}:{},...p.env.NEXT_PUBLIC_DONOTDEV_LICENSE_KEY?{NEXT_PUBLIC_DONOTDEV_LICENSE_KEY:p.env.NEXT_PUBLIC_DONOTDEV_LICENSE_KEY}:{}},da=Qn({routeResult:sa,themeResult:ia,i18nResult:na,assetResult:aa,seoResult:oa,pwaResult:la,serverShimResult:ca,restNextConfig:ra,discoveredPackages:_t,nextVersion:At,isNext15:nr,webpackConfig:ha,rewritesConfig:ua,missingOptionalDeps:ar,env:fa,logger:D});if(D.debug("Next.js config generated"),De){let vt=o?.name||"app",or=bt.getAppRoot();D.info(`Name: ${vt}`),D.info(`URL: ${p.env.NEXT_PUBLIC_APP_URL||"http://localhost:3000"}`),D.info("\u{1F527} Features: auto-detected"),D.info(`App root (final): ${or}`)}return da}}var Zn=fu;export{Zn as default,Zn as defineNextConfig};
|
|
557
557
|
/*! Bundled license information:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
],
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@donotdev/components": "0.0.
|
|
55
|
+
"@donotdev/components": "0.0.9",
|
|
56
56
|
"@sentry/react": "^10.25.0",
|
|
57
57
|
"lucide-react": "^0.562.0",
|
|
58
58
|
"react": "^19.2.3",
|