@donotdev/core 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vite/index.js CHANGED
@@ -311,7 +311,7 @@ export const source = 'empty';
311
311
 
312
312
  export default envData;
313
313
  `},generateInspection:n=>{let{env:e,mode:t}=n;return["/**"," * Generated Environment Variables",` * Mode: ${t}`,` * Generated at: ${new Date().toISOString()}`,` * Total variables: ${Object.keys(e).length}`," */","","```json",JSON.stringify(e,null,2),"```"].join(`
314
- `)},generateManifest:n=>({totalVars:Object.keys(n?.env||{}).length,mode:n?.mode||"development",variables:Object.keys(n?.env||{}),timestamp:Date.now()}),logStats:(n,e,t)=>{let s=Object.keys(n.env).length;t&&t.info(`${e} Env: ${s} VITE_* variables`)}},qe=class{constructor(e,t={}){this.pathResolver=e,this.options=t,this.mode=t.mode||"development",this.appRoot=null}async discoverEnv(){try{let e=this.pathResolver.getAppRoot();if(!e)throw new Error("App root not available in EnvDiscovery");let s={...ws(this.mode,e,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${e}/.env`,errors:[]}}catch(e){return{env:{},mode:this.mode,source:"error",errors:[e.message]}}}};function wt(n={}){return ie({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:C.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:bt,defaultInspectionPath:z.vite.envInspection,manifestFileName:z.manifests.env,configKey:"env",createDiscovery:(e,t)=>new qe(e,{...t,mode:n.mode||t.mode||"development"})})({...n,disableHmr:!0})}q();j();var xt=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,de=class{constructor(e,t={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...t},this.logger=t.logger||{debug:(s,...r)=>{this.options.debug}},this.patterns={selectors:{...Ve.selectors,...this.options.customPatterns?.selectors},themes:{...Ve.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let t=e.replace(/^--/,"");if(!t)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=t.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let r=s.map((a,i)=>{let l=a.replace(/[^a-zA-Z0-9]/g,"");return l?i===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!r||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${r}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(r)?`${r}Var`:r}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,t,s){let r=[],o,a=this.pathResolver.normalizePath(t),i=this._stripComments(e),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(o=l.exec(i))!==null;){let[,u,c,p]=o;if(!u||!p)continue;let g=c.match(this.patterns.themes.themeIcon),d=c.match(this.patterns.themes.themeIsDark),h={name:u,displayName:p,isDark:d?d[1]==="1":!1,meta:{icon:g?.[1]},source:this.pathResolver.getBasename(t)};this._debug(`Discovered theme: ${u} (${p})`),r.push(h),s.themes.set(u,{name:u,displayName:p,isDark:h.isDark,file:a,variables:new Set,meta:h.meta})}return r.length>0&&this._debug(`Extracted ${r.length} themes from ${a}`),r}extractClasses(e,t){(e.match(this.patterns.selectors.class)||[]).forEach(r=>{let o=r.slice(1);o.startsWith("_")||t.classes.add(o)})}extractVariables(e,t,s){(e.match(this.patterns.selectors.variable)||[]).forEach(o=>{o.startsWith("--")&&o.length>2?s==="framework"?t.variables.framework.add(o):t.variables.consumer.add(o):this._debug(`Skipping invalid CSS variable: ${o}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let t=this._stripComments(e),s=new Set,r;for(xt.lastIndex=0;(r=xt.exec(t))!==null;){let o=r[1];o&&o.trim()&&s.add(o.trim())}return Array.from(s)}extractKeyframes(e,t){(e.match(this.patterns.selectors.keyframe)||[]).forEach(r=>{let o=r.replace("@keyframes","").trim();o&&t.keyframes.add(o)})}validateCSS(e){let t=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(o=>{t.push(`Possible malformed CSS variable: ${o}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(o=>{if(!o.includes("--theme-label")&&o.includes("--")){let a=o.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&t.push(`Theme class "${a}" missing --theme-label`)}}),t}extractAll(e,t,s="consumer"){let r={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},o=this.extractThemes(e,t,r);this.extractClasses(e,r),this.extractVariables(e,r,s),this.extractKeyframes(e,r);let a=this.validateCSS(e);return{themes:o,classes:Array.from(r.classes),variables:{framework:Array.from(r.variables.framework),consumer:Array.from(r.variables.consumer),all:[...Array.from(r.variables.framework),...Array.from(r.variables.consumer)].sort()},keyframes:Array.from(r.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,t){this.logger.debug(e,t||"")}};j();var xs=3,Ye="<!-- DNDEV_FONT_PRELOADS -->";function St(n={}){let{debug:e=!1}=n,t=T("font-preload",e,!1),s,r={},o=[],a=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(i){r={root:i.root,base:i.base&&i.base!=="/"?i.base.replace(/\/$/,""):"",outDir:i.build?.outDir??"dist"};try{s=O.getInstance()}catch(l){t.debug(`Font preload: PathResolver not ready: ${l?.message}`)}},async buildStart(){if(!(!s||!s.getAppRoot()))try{let l=await s.resolvePatterns("css"),{consumerFiles:u}=await s.resolveFiles(l,"css");if(!u?.length){o=[xe.Inter],t.debug("Font preload: no consumer CSS, using default Inter");return}let c=new de(s,{debug:e,logger:t}),p=new Set;for(let d of u)try{let h=await s.read(d,{format:"text"});h&&c.extractFontFamilies(h).forEach(I=>p.add(I))}catch(h){t.debug(`Font preload: skip read ${d}: ${h?.message}`)}if(p.size===0){o=[xe.Inter],t.debug("Font preload: no font families in CSS, using default Inter");return}let g=new Set;for(let d of p){let h=xe[d];h&&g.add(h)}o=Array.from(g),t.debug(`Font preload: stems ${o.join(", ")} from CSS`)}catch(l){t.debug(`Font preload: discovery failed, use Inter: ${l?.message}`),o=[xe.Inter]}},generateBundle(i,l){if(!o.length)return;let u=r.base||"",c=[];for(let[p,g]of Object.entries(l)){if(g.type!=="asset"||!p.endsWith(".woff2")&&!p.endsWith(".woff"))continue;let d=p.toLowerCase();if(o.some(F=>d.includes(F))){let F=u?`${u}/${p}`:`/${p}`;c.push(F)}}a=c.slice(0,xs)},writeBundle(){if(!a.length)return;let i=s||O.getInstance(),l=r.root||process.cwd(),u=r.outDir||"dist",c=i.resolvePath(`${u}/index.html`,l);try{if(!i.pathExists(c)){t.debug(`Font preload: index.html not found at ${c}`);return}let p=i.readSync(c,{format:"text"}),g=a.map(d=>`<link rel="preload" as="font" href="${d}" type="font/woff2" crossorigin="anonymous" />`).join(`
314
+ `)},generateManifest:n=>({totalVars:Object.keys(n?.env||{}).length,mode:n?.mode||"development",variables:Object.keys(n?.env||{}),timestamp:Date.now()}),logStats:(n,e,t)=>{let s=Object.keys(n.env).length;t&&t.info(`${e} Env: ${s} VITE_* variables`)}},qe=class{constructor(e,t={}){this.pathResolver=e,this.options=t,this.mode=t.mode||"development",this.appRoot=null}async discoverEnv(){try{let e=this.pathResolver.getAppRoot();if(!e)throw new Error("App root not available in EnvDiscovery");let s={...ws(this.mode,e,"VITE_")};return this.mode==="production"&&(delete s.VITE_USE_FIREBASE_EMULATOR,delete s.VITE_FIREBASE_EMULATOR_HOST,delete s.VITE_FIREBASE_AUTH_EMULATOR_HOST,delete s.VITE_FIREBASE_FIRESTORE_EMULATOR_HOST,delete s.VITE_FIREBASE_FUNCTIONS_EMULATOR_PORT),s.MODE=this.mode,s.DEV=this.mode==="development",s.PROD=this.mode==="production",s.SSR=!1,{env:s,mode:this.mode,source:`${e}/.env`,errors:[]}}catch(e){return{env:{},mode:this.mode,source:"error",errors:[e.message]}}}};function wt(n={}){return ie({pluginName:"dndev-vite-env-discovery",icon:"\u{1F510}",virtualModuleId:C.env,discoveryMethod:"discoverEnv",filePatterns:[],templates:bt,defaultInspectionPath:z.vite.envInspection,manifestFileName:z.manifests.env,configKey:"env",createDiscovery:(e,t)=>new qe(e,{...t,mode:n.mode||t.mode||"development"})})({...n,disableHmr:!0})}j();j();var xt=/--(?:font-family|font-headline)\s*:\s*(?:['"]([^'"]+)['"]|([^;]+?));/g,de=class{constructor(e,t={}){if(!e)throw new Error("CSSExtractor requires PathResolver instance");this.pathResolver=e,this.options={debug:!1,customPatterns:{},...t},this.logger=t.logger||{debug:(s,...r)=>{this.options.debug}},this.patterns={selectors:{...Ve.selectors,...this.options.customPatterns?.selectors},themes:{...Ve.themes,...this.options.customPatterns?.themes}}}cssVarToJsIdentifier(e){if(!e||typeof e!="string")return this._debug(`Invalid CSS variable: ${e}`),null;let t=e.replace(/^--/,"");if(!t)return this._debug(`Empty CSS variable after removing --: ${e}`),null;let s=t.split("-").filter(a=>a.length>0);if(s.length===0)return this._debug(`No valid parts in CSS variable: ${e}`),null;let r=s.map((a,i)=>{let l=a.replace(/[^a-zA-Z0-9]/g,"");return l?i===0?l.toLowerCase():l.charAt(0).toUpperCase()+l.slice(1).toLowerCase():null}).filter(Boolean).join("");return!r||!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r)?(this._debug(`Invalid JavaScript identifier generated from ${e}: ${r}`),null):["const","let","var","function","class","export","import","default","if","else","for","while"].includes(r)?`${r}Var`:r}_stripComments(e){return e.replace(/\/\*[\s\S]*?\*\//g,"")}extractThemes(e,t,s){let r=[],o,a=this.pathResolver.normalizePath(t),i=this._stripComments(e),l=/(?::root\.|\.)([a-z][a-z0-9-]*)\s*\{([^}]*--theme-label\s*:\s*['"]([^'"]+)['"][^}]*)\}/gim;for(;(o=l.exec(i))!==null;){let[,u,c,p]=o;if(!u||!p)continue;let g=c.match(this.patterns.themes.themeIcon),d=c.match(this.patterns.themes.themeIsDark),h={name:u,displayName:p,isDark:d?d[1]==="1":!1,meta:{icon:g?.[1]},source:this.pathResolver.getBasename(t)};this._debug(`Discovered theme: ${u} (${p})`),r.push(h),s.themes.set(u,{name:u,displayName:p,isDark:h.isDark,file:a,variables:new Set,meta:h.meta})}return r.length>0&&this._debug(`Extracted ${r.length} themes from ${a}`),r}extractClasses(e,t){(e.match(this.patterns.selectors.class)||[]).forEach(r=>{let o=r.slice(1);o.startsWith("_")||t.classes.add(o)})}extractVariables(e,t,s){(e.match(this.patterns.selectors.variable)||[]).forEach(o=>{o.startsWith("--")&&o.length>2?s==="framework"?t.variables.framework.add(o):t.variables.consumer.add(o):this._debug(`Skipping invalid CSS variable: ${o}`)})}extractFontFamilies(e){if(!e||typeof e!="string")return[];let t=this._stripComments(e),s=new Set,r;for(xt.lastIndex=0;(r=xt.exec(t))!==null;){let o=r[1];o&&o.trim()&&s.add(o.trim())}return Array.from(s)}extractKeyframes(e,t){(e.match(this.patterns.selectors.keyframe)||[]).forEach(r=>{let o=r.replace("@keyframes","").trim();o&&t.keyframes.add(o)})}validateCSS(e){let t=[],s=e.match(/--[a-zA-Z0-9-_]*[^a-zA-Z0-9-_:;\s]/g);return s&&s.forEach(o=>{t.push(`Possible malformed CSS variable: ${o}`)}),(e.match(/\.[a-z][a-z0-9-]+\s*\{[^}]*\}/gi)||[]).forEach(o=>{if(!o.includes("--theme-label")&&o.includes("--")){let a=o.match(/\.([a-z][a-z0-9-]+)/)?.[1];a&&t.push(`Theme class "${a}" missing --theme-label`)}}),t}extractAll(e,t,s="consumer"){let r={themes:new Map,classes:new Set,variables:{framework:new Set,consumer:new Set},keyframes:new Set},o=this.extractThemes(e,t,r);this.extractClasses(e,r),this.extractVariables(e,r,s),this.extractKeyframes(e,r);let a=this.validateCSS(e);return{themes:o,classes:Array.from(r.classes),variables:{framework:Array.from(r.variables.framework),consumer:Array.from(r.variables.consumer),all:[...Array.from(r.variables.framework),...Array.from(r.variables.consumer)].sort()},keyframes:Array.from(r.keyframes),warnings:a}}getPatterns(){return{...this.patterns}}setPatterns(e){this.patterns={...this.patterns,...e,selectors:{...this.patterns.selectors,...e.selectors},themes:{...this.patterns.themes,...e.themes}}}_debug(e,t){this.logger.debug(e,t||"")}};q();var xs=3,Ye="<!-- DNDEV_FONT_PRELOADS -->";function St(n={}){let{debug:e=!1}=n,t=T("font-preload",e,!1),s,r={},o=[],a=[];return{name:"vite-font-preload-plugin",enforce:"post",configResolved(i){r={root:i.root,base:i.base&&i.base!=="/"?i.base.replace(/\/$/,""):"",outDir:i.build?.outDir??"dist"};try{s=O.getInstance()}catch(l){t.debug(`Font preload: PathResolver not ready: ${l?.message}`)}},async buildStart(){if(!(!s||!s.getAppRoot()))try{let l=await s.resolvePatterns("css"),{consumerFiles:u}=await s.resolveFiles(l,"css");if(!u?.length){o=[xe.Inter],t.debug("Font preload: no consumer CSS, using default Inter");return}let c=new de(s,{debug:e,logger:t}),p=new Set;for(let d of u)try{let h=await s.read(d,{format:"text"});h&&c.extractFontFamilies(h).forEach(I=>p.add(I))}catch(h){t.debug(`Font preload: skip read ${d}: ${h?.message}`)}if(p.size===0){o=[xe.Inter],t.debug("Font preload: no font families in CSS, using default Inter");return}let g=new Set;for(let d of p){let h=xe[d];h&&g.add(h)}o=Array.from(g),t.debug(`Font preload: stems ${o.join(", ")} from CSS`)}catch(l){t.debug(`Font preload: discovery failed, use Inter: ${l?.message}`),o=[xe.Inter]}},generateBundle(i,l){if(!o.length)return;let u=r.base||"",c=[];for(let[p,g]of Object.entries(l)){if(g.type!=="asset"||!p.endsWith(".woff2")&&!p.endsWith(".woff"))continue;let d=p.toLowerCase();if(o.some(F=>d.includes(F))){let F=u?`${u}/${p}`:`/${p}`;c.push(F)}}a=c.slice(0,xs)},writeBundle(){if(!a.length)return;let i=s||O.getInstance(),l=r.root||process.cwd(),u=r.outDir||"dist",c=i.resolvePath(`${u}/index.html`,l);try{if(!i.pathExists(c)){t.debug(`Font preload: index.html not found at ${c}`);return}let p=i.readSync(c,{format:"text"}),g=a.map(d=>`<link rel="preload" as="font" href="${d}" type="font/woff2" crossorigin="anonymous" />`).join(`
315
315
  `);if(p.includes(Ye))p=p.replace(Ye,`${Ye}
316
316
  ${g}`);else{let d=p.indexOf("<!-- Fonts:"),h=d!==-1?p.indexOf("-->",d)+3:p.indexOf("</head>");h!==-1&&(p=p.slice(0,h)+`
317
317
  ${g}`+p.slice(h))}i.writeSync(c,p,{overwrite:!0}),t.debug(`Font preload: injected ${a.length} link(s)`)}catch(p){t.debug(`Font preload: write failed: ${p?.message}`)}}}}j();j();var Oe=class extends te{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=ke("i18n"),a=r.eager||[],i=r.lazy||[],l=(this.options.additionalPaths||[]).map(R=>{let N=R.endsWith(".json")?R:`${R}/*_*.json`;return this.pathResolver.resolveAppPath(N)});l.length>0&&this.logger.debug(`Additional i18n paths configured: ${l.join(", ")}`);let u=r.framework?.eager||[],c=r.framework?.lazy||[];this.logger.debug(`Resolved patterns - eager: ${a.join(", ")}, lazy: ${i.join(", ")}, framework eager: ${u.join(", ")}, framework lazy: ${c.join(", ")}`),u.length===0&&c.length===0&&this.logger.error(`\u26A0\uFE0F Framework i18n patterns are EMPTY! isMonorepo=${this.pathResolver.isMonorepo()}, repoRoot=${this.pathResolver.getRepoRoot()}`);let p=this.pathResolver.normalizePath(t),g=this.pathResolver.normalizePath(s),d=(R,N)=>{let k=this.pathResolver.normalizePath(R),L=this.pathResolver.normalizePath(N);return k.startsWith(L)?k.slice(L.length+1):k},h=a.map(R=>d(R,t)),I=[...i,...l].map(R=>d(R,t)),S=u.map(R=>d(R,s)),_=c.map(R=>d(R,s)),$={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:t},b=await this.pathResolver._globWithNormalization(h,$),w=await this.pathResolver._globWithNormalization(I,$),m={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:s,ignore:o.ignore?.filter(R=>R!=="**/node_modules/**")||[]};this.logger.debug(`\u{1F50D} Searching framework patterns with cwd: ${s}, ignore: ${JSON.stringify(m.ignore)}`);let D=await this.pathResolver._globWithNormalization(S,m),A=await this.pathResolver._globWithNormalization(_,m);this.logger.debug(`Found ${b.length} eager, ${w.length} lazy, ${D.length} framework eager, ${A.length} framework lazy files`),D.length>0?this.logger.debug(`Framework eager files (first 3): ${D.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework eager files found! Patterns were: ${u.join(", ")}`),A.length>0?this.logger.debug(`Framework lazy files (first 3): ${A.slice(0,3).join(", ")}`):this.logger.error(`\u274C NO framework lazy files found! Patterns were: ${c.join(", ")}`);let K=[...new Set([...b,...w,...D,...A])],E=new Set([...b,...D]),x={mapping:{},content:{},eagerNamespaces:new Set,allNamespaces:new Set,supportedLanguages:new Set,files:[]},G=new Map,ye=[...D,...A];for(let R of ye){let N=this._processTranslationFile(R,D.includes(R),t);if(N){let k=`${N.namespace}_${N.language}`;G.set(k,N),x.allNamespaces.add(N.namespace),x.supportedLanguages.add(N.language),D.includes(R)&&x.eagerNamespaces.add(N.namespace)}}let Z=new Set;for(let R of K){if(ye.includes(R))continue;let N=this._processTranslationFile(R,E.has(R),t);if(N){let{namespace:k,language:L,importPath:fe,content:W}=N,le=`${N.namespace}_${N.language}`;if(G.has(le)){let ue=G.get(le);N.content=this._mergeTranslations(ue.content,W)}x.allNamespaces.add(k),x.supportedLanguages.add(L),Z.add(L),E.has(R)&&x.eagerNamespaces.add(k),x.mapping[k]||(x.mapping[k]={}),x.mapping[k][L]=fe,N.content&&(x.content[k]||(x.content[k]={}),x.content[k][L]=N.content),x.files.push({path:R,relativePath:this.pathResolver.getRelativePath(R),namespace:k,language:L,eager:E.has(R),size:N.content?JSON.stringify(N.content).length:0})}}for(let[R,N]of G){let[k,L]=R.split("_");(!x.mapping[k]||!x.mapping[k][L])&&(x.mapping[k]||(x.mapping[k]={}),x.mapping[k][L]=N.importPath,x.content[k]||(x.content[k]={}),x.content[k][L]=N.content)}let oe=Z.size>0?[...Z].sort():[this.options.fallbackLanguage];return{mapping:x.mapping,content:x.content,eagerNamespaces:[...x.eagerNamespaces].sort(),allNamespaces:[...x.allNamespaces].sort(),supportedLanguages:oe,fallbackLanguage:this.options.fallbackLanguage,files:x.files}}_getEmptyResult(){return{mapping:{},content:{},eagerNamespaces:[],allNamespaces:["common"],supportedLanguages:[this.options.fallbackLanguage],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,i=r.match(/^([^_]+)_([^.]+)\.json$/);if(!i)return this.logger.debug(`Invalid translation file name format: ${r}`),null;if([,o,a]=i,!o||!a)return this.logger.debug(`Invalid namespace or language in file: ${r}`),null;let u="./"+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(p){return this.logger.debug(`Error parsing JSON from ${e}: ${p.message}`),null}return{namespace:o,language:a,importPath:u,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 Ss={isEmpty:n=>!n.mapping||Object.keys(n.mapping).length===0,generateModule:(n,e,t="i18n")=>{let{mapping:s,eagerNamespaces:r,supportedLanguages:o,fallbackLanguage:a,stats:i,content:l={}}=n,u={mapping:s,languages:o,eager:r,fallback:a,content:l,storage:{type:"localStorage",prefix:"dndev_i18n_",ttl:1440*60*1e3,encryption:!1,maxSize:5*1024*1024},performance:{cacheSize:1e3,errorCacheTTL:300*1e3},manifest:{totalFiles:i?.totalFiles||0,totalNamespaces:i?.totalNamespaces||0,totalLanguages:i?.totalLanguages||0,eagerNamespaces:i?.eagerNamespaces||0,generatedAt:new Date().toISOString()},debug:e};return`// ${C.i18n} - Generated by @donotdev/config
@@ -572,7 +572,7 @@ export default {
572
572
  files: translationFiles,
573
573
  manifest: i18nManifest,
574
574
  };
575
- `},generateManifest:n=>({namespaces:n.stats?.totalNamespaces||0,languages:n.stats?.totalLanguages||0,fallbackLanguage:n.fallbackLanguage,eagerNamespaces:n.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.supportedLanguages||[],r=Object.keys(n.mapping||{}).filter(o=>o!=="default").length||0;t&&t.info(`${e} I18n: ${s.length} languages, ${r} namespaces`)}},Es=[n=>n.endsWith(".json")&&n.includes("locale"),n=>/[a-z]+_[a-z]{2}\.json$/i.test(n),n=>n.includes("/locales/")&&n.endsWith(".json")];function Et(n={}){return ie({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:C.i18n,DiscoveryClass:Oe,discoveryMethod:"discoverTranslations",filePatterns:Es,templates:Ss,defaultInspectionPath:z.vite.i18nInspection,manifestFileName:z.manifests.i18n,configKey:"i18n",discoveryOptions:{fallbackLanguage:n.fallbackLanguage||"en",...n}})({...n,hmrSmartDetection:!1})}j();q();function Pt(n={}){let e=[],t="";return{name:"dndev-optional-dep-resolver",enforce:"pre",configResolved(){let s=O.getInstance(),r=s.getAppRoot(),o=he.optionalFeatures||[];for(let a of o)s.resolvePackage(a,r)||e.push(a);t=s.getEmptyModulePath(),n.debug&&e.length>0},resolveId(s){return e.includes(s)?t:null}}}function Ke(n){return!n||typeof n!="string"?null:n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0]}function Ps(n){return!n||typeof n!="string"?!1:!n.startsWith(".")&&!n.startsWith("/")&&!n.startsWith("\\")&&!n.startsWith("\0")}function Rs(n,e){if(!n||!e||!e.getRepoRoot())return!1;let s=n;n.startsWith("@fs/")&&(s=n.slice(4));let r=e.resolveRepoPath("packages"),o=e.normalizePath(s);return r&&o.startsWith(r)}function _s(n,e){if(!n||!e)return null;let t=Ke(n);if(!t)return null;let s=e.resolveAppPath(`node_modules/${t}`);return e.pathExists(s)?e.resolveAppPath(`node_modules/${n}`):null}function Rt(n,e,t){return!Ps(n)||!Rs(e,t)?null:_s(n,t)}q();function _t(n={}){let{debug:e=!1,verbose:t=!0}=n,s=T("peer-dependency-resolver",e,t);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(r){let o=O.getInstance(),a=o.getAppRoot();if(!a){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=o,this.appRoot=a},resolveId(r,o){if(!o||!this.appRoot||!this.pathResolver)return null;if(Rt(r,o,this.pathResolver)){let i=Ke(r),l=this.pathResolver.resolveAppPath(`node_modules/${r}`),u=this.pathResolver.resolveAppPath(`node_modules/${i}`);return this.pathResolver.pathExists(u)?r===i?((e||t)&&s.debug(`[PeerDeps] Resolving bare import "${r}" from app's node_modules: ${u}`),u):((e||t)&&s.debug(`[PeerDeps] Resolving subpath "${r}" from app's node_modules: ${l}`),l):(e&&s.debug(`[PeerDeps] Package directory not found: ${u}, skipping resolution`),null)}return null}}}import{VitePWA as $s}from"vite-plugin-pwa";j();var Fe=class extends te{constructor(e,t={}){super(e,{...t})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(e){let{frameworkFiles:t,consumerFiles:s}=e,r=[...t,...s];this.logger.debug(`Processing ${r.length} PWA files`);let o=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),o=[...this.options.assetData.pwaIcons]);let a=await this._analyzePWAFiles(r),i=a.filter(g=>g.type==="manifest"||g.type==="service-worker");o.push(...i);let l=a.filter(g=>g.type==="icon"),u=new Set(o.filter(g=>g.type==="icon").map(g=>g.path)),c=l.filter(g=>!u.has(g.path));o.push(...c);let p=this._generatePWAManifest(o);return{assets:o,manifest:p,totalFiles:r.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(e){let t=[];for(let s of e){let r=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,o=await this._analyzePWAAsset(r);o&&t.push(o)}return t}async _analyzePWAAsset(e){let t=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!t)return null;let s=e.relativePath,r=e.fileName;return r.includes("manifest.json")?this._parseManifestFile(t,s):r.includes("service-worker")||r.includes("sw.")?this._parseServiceWorkerFile(t,s):this._isPWAIcon(r)?this._parseIconFile(e,s):null}_parseManifestFile(e,t){try{let s=typeof e=="string"?JSON.parse(e):e;return{type:"manifest",path:t,content:s,size:typeof e=="string"?e.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(e,t){return{type:"service-worker",path:t,size:e.length,hasWorkbox:e.includes("workbox")}}_parseIconFile(e,t){let s=e.fileName,r=this._extractIconSize(s);return{type:"icon",path:t,size:r,format:e.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(e){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>e.includes(s))}_extractIconSize(e){let t=e.match(/(\d+)x(\d+)/);return t?{width:parseInt(t[1]),height:parseInt(t[2])}:e.includes("favicon")?{width:32,height:32}:e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("icon-192")?{width:192,height:192}:e.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(e){return e.includes("maskable")?"maskable":e.includes("apple-touch")?"apple-touch":e.includes("android-chrome")?"android":"any"}_generatePWAManifest(e){let t=e.filter(o=>o.type==="icon"),r=e.find(o=>o.type==="manifest")?.content||this._getDefaultManifest();return t.length>0&&(r.icons=t.map(o=>({src:`/${o.path}`,sizes:`${o.size.width}x${o.size.height}`,type:`image/${o.format}`,purpose:o.purpose}))),r}_getDefaultManifest(){let e=this.options?.app||{};return{name:e.name,short_name:e.shortName,description:e.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(e){let t=e.manifest||this._getDefaultManifest();return JSON.stringify(t,null,2)}generateServiceWorkerContent(e,t={}){let s=this._getWorkboxDefaults(t),r=t.backgroundSync!==!1&&t.backgroundSync,o=t.precacheManifest||[],a=JSON.stringify(o,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
575
+ `},generateManifest:n=>({namespaces:n.stats?.totalNamespaces||0,languages:n.stats?.totalLanguages||0,fallbackLanguage:n.fallbackLanguage,eagerNamespaces:n.stats?.eagerNamespaces||0,platform:"vite",timestamp:Date.now()}),logConfig:n=>{},logStats:(n,e,t)=>{let s=n.supportedLanguages||[],r=Object.keys(n.mapping||{}).filter(o=>o!=="default").length||0;t&&t.info(`${e} I18n: ${s.length} languages, ${r} namespaces`)}},Es=[n=>n.endsWith(".json")&&n.includes("locale"),n=>/[a-z]+_[a-z]{2}\.json$/i.test(n),n=>n.includes("/locales/")&&n.endsWith(".json")];function Et(n={}){return ie({pluginName:"dndev-vite-i18n-discovery",icon:"\u{1F310}",virtualModuleId:C.i18n,DiscoveryClass:Oe,discoveryMethod:"discoverTranslations",filePatterns:Es,templates:Ss,defaultInspectionPath:z.vite.i18nInspection,manifestFileName:z.manifests.i18n,configKey:"i18n",discoveryOptions:{fallbackLanguage:n.fallbackLanguage||"en",...n}})({...n,hmrSmartDetection:!1})}j();q();function Pt(n={}){let e=[],t="";return{name:"dndev-optional-dep-resolver",enforce:"pre",configResolved(){let s=O.getInstance(),r=s.getAppRoot(),o=he.optionalFeatures||[];for(let a of o)s.resolvePackage(a,r)||e.push(a);t=s.getEmptyModulePath(),n.debug&&e.length>0},resolveId(s){return e.some(r=>s===r||s.startsWith(r+"/"))?t:null}}}function Ke(n){return!n||typeof n!="string"?null:n.startsWith("@")?n.split("/").slice(0,2).join("/"):n.split("/")[0]}function Ps(n){return!n||typeof n!="string"?!1:!n.startsWith(".")&&!n.startsWith("/")&&!n.startsWith("\\")&&!n.startsWith("\0")}function Rs(n,e){if(!n||!e||!e.getRepoRoot())return!1;let s=n;n.startsWith("@fs/")&&(s=n.slice(4));let r=e.resolveRepoPath("packages"),o=e.normalizePath(s);return r&&o.startsWith(r)}function _s(n,e){if(!n||!e)return null;let t=Ke(n);if(!t)return null;let s=e.resolveAppPath(`node_modules/${t}`);return e.pathExists(s)?e.resolveAppPath(`node_modules/${n}`):null}function Rt(n,e,t){return!Ps(n)||!Rs(e,t)?null:_s(n,t)}q();function _t(n={}){let{debug:e=!1,verbose:t=!0}=n,s=T("peer-dependency-resolver",e,t);return{name:"dndev-peer-dependency-resolver",enforce:"pre",configResolved(r){let o=O.getInstance(),a=o.getAppRoot();if(!a){s.warn("App root not set, peer dependency resolution may fail");return}this.pathResolver=o,this.appRoot=a},resolveId(r,o){if(!o||!this.appRoot||!this.pathResolver)return null;if(Rt(r,o,this.pathResolver)){let i=Ke(r),l=this.pathResolver.resolveAppPath(`node_modules/${r}`),u=this.pathResolver.resolveAppPath(`node_modules/${i}`);return this.pathResolver.pathExists(u)?r===i?((e||t)&&s.debug(`[PeerDeps] Resolving bare import "${r}" from app's node_modules: ${u}`),u):((e||t)&&s.debug(`[PeerDeps] Resolving subpath "${r}" from app's node_modules: ${l}`),l):(e&&s.debug(`[PeerDeps] Package directory not found: ${u}, skipping resolution`),null)}return null}}}import{VitePWA as $s}from"vite-plugin-pwa";j();var Fe=class extends te{constructor(e,t={}){super(e,{...t})}_getDiscoveryType(){return"PWA"}async _getPatterns(){return await this.pathResolver.resolvePatterns("pwa")}_getPatternType(){return"pwa"}async _processFiles(e){let{frameworkFiles:t,consumerFiles:s}=e,r=[...t,...s];this.logger.debug(`Processing ${r.length} PWA files`);let o=[];this.options.assetData?.pwaIcons&&(this.logger.debug(`Using ${this.options.assetData.pwaIcons.length} icons from AssetDiscovery`),o=[...this.options.assetData.pwaIcons]);let a=await this._analyzePWAFiles(r),i=a.filter(g=>g.type==="manifest"||g.type==="service-worker");o.push(...i);let l=a.filter(g=>g.type==="icon"),u=new Set(o.filter(g=>g.type==="icon").map(g=>g.path)),c=l.filter(g=>!u.has(g.path));o.push(...c);let p=this._generatePWAManifest(o);return{assets:o,manifest:p,totalFiles:r.length,timestamp:Date.now()}}_getEmptyResult(){return{assets:[],manifest:this._getDefaultManifest(),totalFiles:0,timestamp:Date.now()}}_getDiscoverySummary(){return`${this.cache?.assets?.length||0} PWA assets discovered`}async _analyzePWAFiles(e){let t=[];for(let s of e){let r=typeof s=="string"?{absolutePath:s,relativePath:this.pathResolver.getRelativePath(s),fileName:s.split("/").pop()||"",extension:(s.split(".").pop()||"").toLowerCase()}:s,o=await this._analyzePWAAsset(r);o&&t.push(o)}return t}async _analyzePWAAsset(e){let t=await this.pathResolver.read(e.absolutePath,{format:"text"});if(!t)return null;let s=e.relativePath,r=e.fileName;return r.includes("manifest.json")?this._parseManifestFile(t,s):r.includes("service-worker")||r.includes("sw.")?this._parseServiceWorkerFile(t,s):this._isPWAIcon(r)?this._parseIconFile(e,s):null}_parseManifestFile(e,t){try{let s=typeof e=="string"?JSON.parse(e):e;return{type:"manifest",path:t,content:s,size:typeof e=="string"?e.length:JSON.stringify(s).length}}catch(s){return this.logger.debug(`Failed to parse manifest: ${s.message}`),null}}_parseServiceWorkerFile(e,t){return{type:"service-worker",path:t,size:e.length,hasWorkbox:e.includes("workbox")}}_parseIconFile(e,t){let s=e.fileName,r=this._extractIconSize(s);return{type:"icon",path:t,size:r,format:e.extension,purpose:this._getIconPurpose(s)}}_isPWAIcon(e){return["icon","logo","apple-touch-icon","android-chrome","favicon"].some(s=>e.includes(s))}_extractIconSize(e){let t=e.match(/(\d+)x(\d+)/);return t?{width:parseInt(t[1]),height:parseInt(t[2])}:e.includes("favicon")?{width:32,height:32}:e.includes("apple-touch-icon")?{width:180,height:180}:e.includes("icon-192")?{width:192,height:192}:e.includes("icon-512")?{width:512,height:512}:{width:192,height:192}}_getIconPurpose(e){return e.includes("maskable")?"maskable":e.includes("apple-touch")?"apple-touch":e.includes("android-chrome")?"android":"any"}_generatePWAManifest(e){let t=e.filter(o=>o.type==="icon"),r=e.find(o=>o.type==="manifest")?.content||this._getDefaultManifest();return t.length>0&&(r.icons=t.map(o=>({src:`/${o.path}`,sizes:`${o.size.width}x${o.size.height}`,type:`image/${o.format}`,purpose:o.purpose}))),r}_getDefaultManifest(){let e=this.options?.app||{};return{name:e.name,short_name:e.shortName,description:e.description,start_url:"/",display:"standalone",background_color:"#ffffff",theme_color:"#000000",icons:[]}}generateManifestContent(e){let t=e.manifest||this._getDefaultManifest();return JSON.stringify(t,null,2)}generateServiceWorkerContent(e,t={}){let s=this._getWorkboxDefaults(t),r=t.backgroundSync!==!1&&t.backgroundSync,o=t.precacheManifest||[],a=JSON.stringify(o,null,2);return`// Generated by @donotdev/config - PWA Service Worker with Workbox
576
576
  // Generated at ${new Date().toISOString()}
577
577
 
578
578
  importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');