pickier 0.1.40 → 0.1.41
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/dist/bin/cli.js +1 -1
- package/dist/{chunk-j2yn05ka.js → chunk-fwcbj9dd.js} +1 -1
- package/dist/{chunk-34yzzbec.js → chunk-hd1a5cpg.js} +1 -1
- package/dist/{chunk-nwytx79z.js → chunk-jtgkwhm9.js} +1 -1
- package/dist/{chunk-db1t9ezz.js → chunk-kd24156y.js} +1 -1
- package/dist/chunk-qj39x47r.js +2 -0
- package/dist/{chunk-vq1weh7a.js → chunk-ryc0ac29.js} +1 -1
- package/dist/{chunk-5wzkpgv6.js → chunk-sa6phv2n.js} +1 -1
- package/dist/{chunk-cbqydxbp.js → chunk-y0y1q8bv.js} +16 -16
- package/dist/src/index.js +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-p4y6z6j6.js +0 -2
package/dist/bin/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
import{L as N}from"../chunk-h6ac3d60.js";import J from"process";async function I(){let E=J.argv.slice(2),Q=E[0]==="run",C=Q?1:0,O=Q?"auto":"lint",X=!1,Y=!1,Z=!1,_=!1,$,T=[],x=!0;for(let y=C;y<E.length;y++){let q=E[y];if(q==="--mode")O=E[++y]||"auto";else if(q==="--format")Z=!0,O="format";else if(q==="--check")X=!0;else if(q==="--write")Y=!0;else if(q==="--config")$=E[++y];else if(q==="--verbose")_=!0;else if(q==="--ext"||q==="--ignore-path")y++;else if(q==="--fix"||q==="--dry-run"||q==="--reporter"||q==="--max-warnings"||q==="--cache"){x=!1,T.length=0;break}else if(q.startsWith("--"));else T.push(q)}if(x&&(O==="format"||O==="auto"||O==="lint")&&T.length>0){let{runUnified:y}=await import("../chunk-
|
|
3
|
+
import{L as N}from"../chunk-h6ac3d60.js";import J from"process";async function I(){let E=J.argv.slice(2),Q=E[0]==="run",C=Q?1:0,O=Q?"auto":"lint",X=!1,Y=!1,Z=!1,_=!1,$,T=[],x=!0;for(let y=C;y<E.length;y++){let q=E[y];if(q==="--mode")O=E[++y]||"auto";else if(q==="--format")Z=!0,O="format";else if(q==="--check")X=!0;else if(q==="--write")Y=!0;else if(q==="--config")$=E[++y];else if(q==="--verbose")_=!0;else if(q==="--ext"||q==="--ignore-path")y++;else if(q==="--fix"||q==="--dry-run"||q==="--reporter"||q==="--max-warnings"||q==="--cache"){x=!1,T.length=0;break}else if(q.startsWith("--"));else T.push(q)}if(x&&(O==="format"||O==="auto"||O==="lint")&&T.length>0){let{runUnified:y}=await import("../chunk-qj39x47r.js"),q=await y(T,{mode:O,check:X,write:Y,verbose:_,config:$});J.exit(q)}let{CLI:L}=await import("../chunk-88xjkex3.js"),{version:F}=await import("../chunk-ryc0ac29.js"),H=new L("pickier"),V=(y)=>{let[q,B]=y;return[Array.isArray(q)?q.filter((W)=>typeof W==="string"):[],B&&typeof B==="object"?B:{}]};H.command("[...globs]","Lint files (default)").option("--fix","Auto-fix lint problems").option("--format","Format files instead of linting").option("--dry-run","Simulate fixes without writing").option("--check","Check formatting without writing (CI-friendly)").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier .").example("pickier . --fix").example("pickier . --format").example("pickier src --fix --verbose").action(async(...y)=>{let[q,B]=V(y);if(q.length===0){H.outputHelp();return}let{runUnified:K}=await import("../chunk-qj39x47r.js"),D;if(B.format){if(D="format",!B.check)B.write=!0}else D="lint";let W=await K(q,{...B,mode:D});J.exit(W)}),H.command("lint [...globs]","[DEPRECATION] Use `pickier [...globs]` instead. Lint files").option("--fix","Auto-fix problems").option("--dry-run","Simulate fixes without writing").option("--max-warnings <n>","Max warnings before non-zero exit",{default:-1}).option("--reporter <name>","stylish|json|compact",{default:"stylish"}).option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache").option("--verbose","Verbose output").example("pickier lint .").example("pickier lint src --fix").example('pickier lint "src/**/*.{ts,tsx}" --reporter json').action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-qj39x47r.js"),D=await K(q,{...B,mode:"lint"});J.exit(D)}),H.command("format [...globs]","[DEPRECATION] Use `pickier [...globs] --format` instead. Format files").option("--write","Write changes to files").option("--check","Check without writing (CI-friendly)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file").option("--ext <exts>","Comma-separated extensions").option("--verbose","Verbose output").example("pickier format . --write").example("pickier format . --check").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-qj39x47r.js"),D=await K(q,{...B,mode:"format"});J.exit(D)}),H.command("run [...globs]","Unified mode (auto, lint, or format)").option("--mode <mode>","auto|lint|format",{default:"auto"}).option("--fix","Auto-fix problems (lint mode)").option("--dry-run","Simulate fixes without writing (lint mode)").option("--max-warnings <n>","Max warnings before non-zero exit (lint mode)",{default:-1}).option("--reporter <name>","stylish|json|compact (lint mode)",{default:"stylish"}).option("--write","Write changes to files (format mode)").option("--check","Check without writing (format mode)").option("--config <path>","Path to pickier config").option("--ignore-path <file>","Ignore file (like .gitignore)").option("--ext <exts>","Comma-separated extensions").option("--cache","Enable cache (lint mode)").option("--verbose","Verbose output").example("pickier run . --mode lint --fix").example("pickier run . --mode format --write").action(async(...y)=>{let[q,B]=V(y),{runUnified:K}=await import("../chunk-qj39x47r.js"),D=await K(q,B);J.exit(D)}),H.command("version","Show the version of the CLI").action(async()=>{let{version:y}=await import("../chunk-ryc0ac29.js");J.stdout.write(`${y}
|
|
4
4
|
`)}),H.version(F),H.help(),H.parse()}I().catch((E)=>{let Q=E instanceof Error?E.message:String(E);J.stderr.write(`pickier: ${Q}
|
|
5
5
|
`),J.exit(1)});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-
|
|
2
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-kd24156y.js";import"./chunk-y0y1q8bv.js";import"./chunk-sa6phv2n.js";import"./chunk-h6ac3d60.js";export{d as scanContentOptimized,e as scanContent,b as runLintProgrammatic,f as runLint,a as lintText,c as applyPlugins};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{D as H,k as G}from"./chunk-
|
|
2
|
+
import{D as H,k as G}from"./chunk-y0y1q8bv.js";import{L as K}from"./chunk-h6ac3d60.js";import{readFileSync as M,statSync as N,writeFileSync as Q}from"fs";import{isAbsolute as R,resolve as T}from"path";import U from"process";async function w(k,j){let B=j.mode||"auto";if(B==="format"&&k.length===1&&!/[*?[\]{}()!]/.test(k[0]))try{let q=k[0],z=R(q)?q:T(U.cwd(),q);if(N(z).isFile()){let J=await H(j.config),D=M(z,"utf8"),E=G(D,J,z);if(j.check&&E!==D)return 1;if(j.write&&E!==D)Q(z,E,"utf8");return 0}}catch{}let{runLint:x}=await import("./chunk-fwcbj9dd.js");if(B==="lint")return x(k,j);if(B==="format"){let q={...j,fix:!0,dryRun:!!j.check,ext:j.ext,_formatOnly:!0};return x(k,q)}if(!(j.fix===!0||j.write===!0||j.check===!0))return x(k,j);let I={...j,fix:!0,dryRun:!!j.check,ext:j.ext};return x(k,I)}
|
|
3
3
|
export{w as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{I as a,J as b,K as c}from"./chunk-
|
|
2
|
+
import{I as a,J as b,K as c}from"./chunk-sa6phv2n.js";import"./chunk-h6ac3d60.js";export{b as getConfig,a as defaultConfig,c as config};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m as K9,n as L7,o as q9,p as t0,r as v0,s as X1,t as xY}from"./chunk-cbqydxbp.js";import{L as g0}from"./chunk-h6ac3d60.js";import{readdirSync as pY,readFileSync as hY,statSync as h8,writeFileSync as W9}from"fs";import{isAbsolute as j1,join as uY,relative as p8,resolve as N1,sep as mY}from"path";import P0 from"process";import{existsSync as _9,statSync as F9}from"fs";import{existsSync as G7,mkdirSync as iY,readdirSync as tY,writeFileSync as eY}from"fs";import{homedir as Y1}from"os";import{dirname as B9,resolve as O0}from"path";import e0 from"process";import{join as $z,relative as Zz,resolve as w9}from"path";import Y$ from"process";import{existsSync as $Z,mkdirSync as t2,readdirSync as e2,writeFileSync as $q}from"fs";import{homedir as d8}from"os";import{dirname as Xq,resolve as R0}from"path";import O1 from"process";import{join as Jz,relative as Xz,resolve as M9}from"path";import z$ from"process";import{existsSync as ZZ,mkdirSync as qq,readdirSync as Uq,writeFileSync as Wq}from"fs";import{dirname as Hq,resolve as Q$}from"path";import q7 from"process";import{Buffer as s0}from"buffer";import{createCipheriv as Yz,createDecipheriv as zz,randomBytes as o8}from"crypto";import{closeSync as c8,createReadStream as j9,createWriteStream as Qz,existsSync as r8,fsyncSync as N9,openSync as T9,writeFileSync as Gz}from"fs";import{access as qz,constants as E9,mkdir as Uz,readdir as m1,rename as D9,stat as z1,unlink as d1,writeFile as l8}from"fs/promises";import{join as Q1}from"path";import N0 from"process";import{pipeline as Wz}from"stream/promises";import{createGzip as R9}from"zlib";import G1 from"process";import o0 from"process";import{Buffer as m0}from"buffer";import{createCipheriv as Kz,createDecipheriv as Hz,randomBytes as a8}from"crypto";import{closeSync as s8,createReadStream as O9,createWriteStream as Vz,existsSync as o1,fsyncSync as L9,openSync as P9,writeFileSync as Az}from"fs";import{access as _z,constants as C9,mkdir as Fz,readdir as c1,rename as I9,stat as q1,unlink as r1,writeFile as n8}from"fs/promises";import{isAbsolute as Bz,join as U1,resolve as wz}from"path";import J0 from"process";import{pipeline as Mz}from"stream/promises";import{createGzip as S9}from"zlib";import W1 from"process";import c0 from"process";import l1 from"process";import{existsSync as a1}from"fs";import{resolve as i8}from"path";import{existsSync as jz}from"fs";import{existsSync as Nz,readdirSync as Tz}from"fs";import{extname as t8,resolve as v9}from"path";import Ez from"process";import{join as DQ,relative as RQ,resolve as o9}from"path";import V$ from"process";import{Buffer as d0}from"buffer";import{createCipheriv as PQ,createDecipheriv as CQ,randomBytes as X7}from"crypto";import{closeSync as Y7,createReadStream as c9,createWriteStream as IQ,existsSync as n1,fsyncSync as r9,openSync as l9,writeFileSync as SQ}from"fs";import{access as vQ,constants as a9,mkdir as yQ,readdir as i1,rename as s9,stat as K1,unlink as t1,writeFile as z7}from"fs/promises";import{isAbsolute as bQ,join as H1,resolve as kQ}from"path";import X0 from"process";import{pipeline as fQ}from"stream/promises";import{createGzip as n9}from"zlib";import V1 from"process";import r0 from"process";var rY=Object.defineProperty;var lY=($)=>$;function aY($,J){this[$]=lY.bind(null,J)}var sY=($,J)=>{for(var Z in J)rY($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:aY.bind(J,Z)})},nY=($,J)=>()=>($&&(J=$($=0)),J);var e9={};sY(e9,{withErrorRecovery:()=>YZ,tryLoadConfig:()=>rz,loadConfigWithResult:()=>oz,loadConfig:()=>UZ,isRetryableError:()=>xz,isConfigNotFoundError:()=>gz,isBunfigError:()=>zZ,globalPerformanceMonitor:()=>C1,globalCache:()=>A1,getEnvOrDefault:()=>pz,generateConfigTypes:()=>lz,defaultGeneratedDir:()=>BZ,defaultConfigDir:()=>FZ,deepMergeWithArrayStrategy:()=>T7,deepMerge:()=>QZ,createLibraryConfig:()=>az,config:()=>cz,bunfigPlugin:()=>sz,applyEnvVarsToConfig:()=>R1,TypeGenerationError:()=>_7,SchemaValidationError:()=>P1,PluginError:()=>B7,PerformanceMonitor:()=>M7,FileSystemError:()=>A7,ErrorFactory:()=>n0,EnvVarError:()=>H$,EnvProcessor:()=>_$,ConfigValidator:()=>E7,ConfigValidationError:()=>H7,ConfigNotFoundError:()=>K$,ConfigMergeError:()=>V7,ConfigLoader:()=>D7,ConfigLoadError:()=>L1,ConfigFileLoader:()=>F$,ConfigCache:()=>w7,CacheUtils:()=>KZ,BunfigError:()=>C0,BrowserConfigError:()=>F7,ArrayMergeStrategies:()=>AZ});class w7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!_9($))return!0;return F9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=_9(Z)?F9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class M7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function Dz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function Rz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function Oz($){return $.getStats().size*2}function j7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&q0(J[0])&&"id"in J[0]&&J[0].id===3&&q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(q0(J)&&q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(q0($)&&"arr"in $&&Array.isArray($.arr)&&q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&q0(J[0])&&q0($[0])){let X=[...J];for(let Y of $)if(q0(Y)&&"name"in Y){if(!X.find((Q)=>q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(q0(Y)&&"path"in Y){if(!X.find((Q)=>q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>G$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!q0(J)||!q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(q0(Y)&&q0(Z[X]))Z[X]=j7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&q0(Y[0])&&q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(q0(Q)&&"name"in Q){if(!z.find((q)=>q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(q0(Q)&&"path"in Q){if(!z.find((q)=>q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>G$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function G$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!G$($[Z],J[Z]))return!1;return!0}if(q0($)&&q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!G$($[Y],J[Y]))return!1}return!0}return!1}function q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function Lz($,J){if(!ZZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return j7(J,X)}catch{return null}}catch{return null}}async function Pz({name:$="",cwd:J,defaultConfig:Z}){let X=J||q7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=Q$(X,`${Q}${G}`),U=await Lz(q,Z);if(U!==null)return U}try{let Q=Q$(X,"package.json");if(ZZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return j7(Z,q)}catch{}}}catch{}return Z}function Cz($,J={}){let Z=z$.cwd();while(Z.includes("storage"))Z=M9(Z,"..");let X=M9(Z,$||"");if(J?.relative)return Xz(z$.cwd(),X);return X}async function Iz(){try{let $=await Pz({name:"clarity",defaultConfig:$$,cwd:z$.cwd(),endpoint:"",headers:{}});return{...$$,...$}}catch{return $$}}function H0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class JZ{async format($){let J=await Sz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:G1.pid,hostname:J(),environment:G1.env.NODE_ENV||"development",platform:G1.platform,version:G1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:G1.env.NODE_ENV||G1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class q${name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...W7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new JZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??N0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Z$};return{...Z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:W7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await qz(this.config.logDirectory,E9.F_OK|E9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Uz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:s0.from($);try{if(!r8(this.currentLogFile))await l8(this.currentLogFile,"",{mode:420});if(Y=T9(this.currentLogFile,"a",420),Gz(Y,q,{flag:"a"}),N9(Y),Y!==void 0)c8(Y),Y=void 0;if((await z1(this.currentLogFile)).size===0){if(await l8(this.currentLogFile,q,{flag:"w",mode:420}),(await z1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{c8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Q1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Q1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return Q1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(H0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return o8(16).toString("hex")}generateKey(){return o8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=o8(16),X=Yz("aes-256-gcm",J,Z),Y=s0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:s0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=R9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(s0.from(s0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(H0())return;let $=await z1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await m1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await z1(Z).catch(()=>null))try{if(await D9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await d1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await l8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await z1(Z).catch(()=>null))await D9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await m1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await d1(Q1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=j9($),X=Qz(J),Y=R9();await Wz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r8(this.currentLogFile))try{let $=T9(this.currentLogFile,"r+");N9($),c8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!H0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await m1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await d1(Q1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?G0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=N0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${G0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!H0()){let U=HZ[$],W=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
|
|
2
|
+
import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m as K9,n as L7,o as q9,p as t0,r as v0,s as X1,t as xY}from"./chunk-y0y1q8bv.js";import{L as g0}from"./chunk-h6ac3d60.js";import{readdirSync as pY,readFileSync as hY,statSync as h8,writeFileSync as W9}from"fs";import{isAbsolute as j1,join as uY,relative as p8,resolve as N1,sep as mY}from"path";import P0 from"process";import{existsSync as _9,statSync as F9}from"fs";import{existsSync as G7,mkdirSync as iY,readdirSync as tY,writeFileSync as eY}from"fs";import{homedir as Y1}from"os";import{dirname as B9,resolve as O0}from"path";import e0 from"process";import{join as $z,relative as Zz,resolve as w9}from"path";import Y$ from"process";import{existsSync as $Z,mkdirSync as t2,readdirSync as e2,writeFileSync as $q}from"fs";import{homedir as d8}from"os";import{dirname as Xq,resolve as R0}from"path";import O1 from"process";import{join as Jz,relative as Xz,resolve as M9}from"path";import z$ from"process";import{existsSync as ZZ,mkdirSync as qq,readdirSync as Uq,writeFileSync as Wq}from"fs";import{dirname as Hq,resolve as Q$}from"path";import q7 from"process";import{Buffer as s0}from"buffer";import{createCipheriv as Yz,createDecipheriv as zz,randomBytes as o8}from"crypto";import{closeSync as c8,createReadStream as j9,createWriteStream as Qz,existsSync as r8,fsyncSync as N9,openSync as T9,writeFileSync as Gz}from"fs";import{access as qz,constants as E9,mkdir as Uz,readdir as m1,rename as D9,stat as z1,unlink as d1,writeFile as l8}from"fs/promises";import{join as Q1}from"path";import N0 from"process";import{pipeline as Wz}from"stream/promises";import{createGzip as R9}from"zlib";import G1 from"process";import o0 from"process";import{Buffer as m0}from"buffer";import{createCipheriv as Kz,createDecipheriv as Hz,randomBytes as a8}from"crypto";import{closeSync as s8,createReadStream as O9,createWriteStream as Vz,existsSync as o1,fsyncSync as L9,openSync as P9,writeFileSync as Az}from"fs";import{access as _z,constants as C9,mkdir as Fz,readdir as c1,rename as I9,stat as q1,unlink as r1,writeFile as n8}from"fs/promises";import{isAbsolute as Bz,join as U1,resolve as wz}from"path";import J0 from"process";import{pipeline as Mz}from"stream/promises";import{createGzip as S9}from"zlib";import W1 from"process";import c0 from"process";import l1 from"process";import{existsSync as a1}from"fs";import{resolve as i8}from"path";import{existsSync as jz}from"fs";import{existsSync as Nz,readdirSync as Tz}from"fs";import{extname as t8,resolve as v9}from"path";import Ez from"process";import{join as DQ,relative as RQ,resolve as o9}from"path";import V$ from"process";import{Buffer as d0}from"buffer";import{createCipheriv as PQ,createDecipheriv as CQ,randomBytes as X7}from"crypto";import{closeSync as Y7,createReadStream as c9,createWriteStream as IQ,existsSync as n1,fsyncSync as r9,openSync as l9,writeFileSync as SQ}from"fs";import{access as vQ,constants as a9,mkdir as yQ,readdir as i1,rename as s9,stat as K1,unlink as t1,writeFile as z7}from"fs/promises";import{isAbsolute as bQ,join as H1,resolve as kQ}from"path";import X0 from"process";import{pipeline as fQ}from"stream/promises";import{createGzip as n9}from"zlib";import V1 from"process";import r0 from"process";var rY=Object.defineProperty;var lY=($)=>$;function aY($,J){this[$]=lY.bind(null,J)}var sY=($,J)=>{for(var Z in J)rY($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:aY.bind(J,Z)})},nY=($,J)=>()=>($&&(J=$($=0)),J);var e9={};sY(e9,{withErrorRecovery:()=>YZ,tryLoadConfig:()=>rz,loadConfigWithResult:()=>oz,loadConfig:()=>UZ,isRetryableError:()=>xz,isConfigNotFoundError:()=>gz,isBunfigError:()=>zZ,globalPerformanceMonitor:()=>C1,globalCache:()=>A1,getEnvOrDefault:()=>pz,generateConfigTypes:()=>lz,defaultGeneratedDir:()=>BZ,defaultConfigDir:()=>FZ,deepMergeWithArrayStrategy:()=>T7,deepMerge:()=>QZ,createLibraryConfig:()=>az,config:()=>cz,bunfigPlugin:()=>sz,applyEnvVarsToConfig:()=>R1,TypeGenerationError:()=>_7,SchemaValidationError:()=>P1,PluginError:()=>B7,PerformanceMonitor:()=>M7,FileSystemError:()=>A7,ErrorFactory:()=>n0,EnvVarError:()=>H$,EnvProcessor:()=>_$,ConfigValidator:()=>E7,ConfigValidationError:()=>H7,ConfigNotFoundError:()=>K$,ConfigMergeError:()=>V7,ConfigLoader:()=>D7,ConfigLoadError:()=>L1,ConfigFileLoader:()=>F$,ConfigCache:()=>w7,CacheUtils:()=>KZ,BunfigError:()=>C0,BrowserConfigError:()=>F7,ArrayMergeStrategies:()=>AZ});class w7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!_9($))return!0;return F9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=_9(Z)?F9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class M7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function Dz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function Rz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function Oz($){return $.getStats().size*2}function j7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&q0(J[0])&&"id"in J[0]&&J[0].id===3&&q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(q0(J)&&q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(q0($)&&"arr"in $&&Array.isArray($.arr)&&q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&q0(J[0])&&q0($[0])){let X=[...J];for(let Y of $)if(q0(Y)&&"name"in Y){if(!X.find((Q)=>q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(q0(Y)&&"path"in Y){if(!X.find((Q)=>q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>G$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!q0(J)||!q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(q0(Y)&&q0(Z[X]))Z[X]=j7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&q0(Y[0])&&q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(q0(Q)&&"name"in Q){if(!z.find((q)=>q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(q0(Q)&&"path"in Q){if(!z.find((q)=>q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>G$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function G$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!G$($[Z],J[Z]))return!1;return!0}if(q0($)&&q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!G$($[Y],J[Y]))return!1}return!0}return!1}function q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function Lz($,J){if(!ZZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return j7(J,X)}catch{return null}}catch{return null}}async function Pz({name:$="",cwd:J,defaultConfig:Z}){let X=J||q7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=Q$(X,`${Q}${G}`),U=await Lz(q,Z);if(U!==null)return U}try{let Q=Q$(X,"package.json");if(ZZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return j7(Z,q)}catch{}}}catch{}return Z}function Cz($,J={}){let Z=z$.cwd();while(Z.includes("storage"))Z=M9(Z,"..");let X=M9(Z,$||"");if(J?.relative)return Xz(z$.cwd(),X);return X}async function Iz(){try{let $=await Pz({name:"clarity",defaultConfig:$$,cwd:z$.cwd(),endpoint:"",headers:{}});return{...$$,...$}}catch{return $$}}function H0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class JZ{async format($){let J=await Sz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:G1.pid,hostname:J(),environment:G1.env.NODE_ENV||"development",platform:G1.platform,version:G1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:G1.env.NODE_ENV||G1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class q${name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...W7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new JZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??N0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Z$};return{...Z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:W7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await qz(this.config.logDirectory,E9.F_OK|E9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Uz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:s0.from($);try{if(!r8(this.currentLogFile))await l8(this.currentLogFile,"",{mode:420});if(Y=T9(this.currentLogFile,"a",420),Gz(Y,q,{flag:"a"}),N9(Y),Y!==void 0)c8(Y),Y=void 0;if((await z1(this.currentLogFile)).size===0){if(await l8(this.currentLogFile,q,{flag:"w",mode:420}),(await z1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{c8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Q1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Q1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return Q1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(H0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return o8(16).toString("hex")}generateKey(){return o8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=o8(16),X=Yz("aes-256-gcm",J,Z),Y=s0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:s0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=R9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(s0.from(s0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(H0())return;let $=await z1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await m1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await z1(Z).catch(()=>null))try{if(await D9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await d1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await l8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await z1(Z).catch(()=>null))await D9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await m1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await d1(Q1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=j9($),X=Qz(J),Y=R9();await Wz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r8(this.currentLogFile))try{let $=T9(this.currentLogFile,"r+");N9($),c8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!H0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await m1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await d1(Q1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?G0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=N0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${G0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!H0()){let U=HZ[$],W=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
|
|
3
3
|
`);for(let V of H)if(V.trim()&&!V.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:G0.gray(` ${V}`),level:$,showTimestamp:!1}))}break}}else if(!H0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let q=`${z} ${this.environment}.${$.toUpperCase()}: ${Q}
|
|
4
4
|
`;if(G)q+=`${G}
|
|
5
5
|
`;q=q.replace(this.ANSI_PATTERN,""),await this.writeToFile(q)}time($){let J=performance.now();if(this.fancy&&!H0()){let Z=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:G0.blue("\u25D0"),tag:Z,message:`${G0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-h6ac3d60.js";var e="pickier",u="module",t="0.1.
|
|
2
|
+
import"./chunk-h6ac3d60.js";var e="pickier",u="module",t="0.1.41",r="Format, lint and more in a fraction of seconds.",s="Chris Breuer <chris@stacksjs.org>",l="MIT",p="https://github.com/pickier/pickier#readme",b={type:"git",url:"git+https://github.com/pickier/pickier.git"},m={url:"https://github.com/pickier/pickier/issues"},c=["pickier","linter","formatter","bun","fast"],o={".":{types:"./dist/index.d.ts",import:"./dist/src/index.js"},"./*":{import:"./dist/*"}},a="./dist/src/index.js",x="./dist/index.d.ts",d={pickier:"./dist/bin/cli.js"},w=["README.md","dist"],k={build:"bun --bun build.ts","build:bin":"bun --bun build.ts && bun run compile",compile:"bun build ./bin/cli.ts --compile --minify --outfile bin/pickier","compile:all":"bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:linux-x64-musl && bun run compile:linux-arm64-musl && bun run compile:windows-x64 && bun run compile:windows-arm64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64","compile:linux-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/pickier-linux-x64","compile:linux-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/pickier-linux-arm64","compile:linux-x64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64-musl --outfile bin/pickier-linux-x64-musl","compile:linux-arm64-musl":"bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64-musl --outfile bin/pickier-linux-arm64-musl","compile:windows-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/pickier-windows-x64.exe","compile:windows-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-windows-arm64 --outfile bin/pickier-windows-arm64.exe","compile:darwin-x64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/pickier-darwin-x64","compile:darwin-arm64":"bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/pickier-darwin-arm64",zip:"bun run zip:all","zip:all":"bun run zip:linux-x64 && bun run zip:linux-arm64 && bun run zip:linux-x64-musl && bun run zip:linux-arm64-musl && bun run zip:windows-x64 && bun run zip:windows-arm64 && bun run zip:darwin-x64 && bun run zip:darwin-arm64","zip:linux-x64":"zip -j bin/pickier-linux-x64.zip bin/pickier-linux-x64","zip:linux-arm64":"zip -j bin/pickier-linux-arm64.zip bin/pickier-linux-arm64","zip:linux-x64-musl":"zip -j bin/pickier-linux-x64-musl.zip bin/pickier-linux-x64-musl","zip:linux-arm64-musl":"zip -j bin/pickier-linux-arm64-musl.zip bin/pickier-linux-arm64-musl","zip:windows-x64":"zip -j bin/pickier-windows-x64.zip bin/pickier-windows-x64.exe","zip:windows-arm64":"zip -j bin/pickier-windows-arm64.zip bin/pickier-windows-arm64.exe","zip:darwin-x64":"zip -j bin/pickier-darwin-x64.zip bin/pickier-darwin-x64","zip:darwin-arm64":"zip -j bin/pickier-darwin-arm64.zip bin/pickier-darwin-arm64",prepublishOnly:"bun --bun run build && bun run compile:all && bun run zip",test:"PICKIER_NO_AUTO_CONFIG=1 bun test --coverage","test:core":"PICKIER_NO_AUTO_CONFIG=1 bun test test/core","test:format":"PICKIER_NO_AUTO_CONFIG=1 bun test test/format","test:lint":"PICKIER_NO_AUTO_CONFIG=1 bun test test/lint","test:rules":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules","test:rules:sort":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/sort","test:rules:style":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/style","test:rules:quality":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/quality","test:rules:imports":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/imports","test:rules:typescript":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/typescript","test:rules:regexp":"PICKIER_NO_AUTO_CONFIG=1 bun test test/rules/regexp","test:plugin":"PICKIER_NO_AUTO_CONFIG=1 bun test test/plugin","test:watch":"PICKIER_NO_AUTO_CONFIG=1 bun test --watch"},I={"@stacksjs/clarity":"^0.3.24","@stacksjs/clapp":"^0.2.3"},O={"@stacksjs/ts-spell-check":"^0.1.0"},_={bunfig:"^0.15.13"},z={name:e,type:u,version:t,description:r,author:s,license:l,homepage:p,repository:b,bugs:m,keywords:c,exports:o,module:a,types:x,bin:d,files:w,scripts:k,dependencies:I,optionalDependencies:O,devDependencies:_};export{t as version,x as types,u as type,k as scripts,b as repository,O as optionalDependencies,e as name,a as module,l as license,c as keywords,p as homepage,w as files,o as exports,_ as devDependencies,r as description,I as dependencies,z as default,m as bugs,d as bin,s as author};
|
|
@@ -58,5 +58,5 @@ export type ConfigOf = Config
|
|
|
58
58
|
`;Y+=`| Variable | Type | Description | Example |
|
|
59
59
|
`,Y+=`|----------|------|-------------|----------|
|
|
60
60
|
`;for(let Z of Q)Y+=`| \`${Z.key}\` | ${Z.type} | ${Z.description} | \`${Z.example}\` |
|
|
61
|
-
`;return Y}}function L8(Q,X,Y={}){return _Z(Q,X,Y,new WeakMap)}function _Z(Q,X,Y,Z){let{arrayMergeMode:$="replace",skipNullish:H=!1,customMerger:U}=Y;if(X===null||X===void 0)return H?Q:X;if(U){let G=U(Q,X);if(G!==void 0)return G}if(Array.isArray(X)||Array.isArray(Q))return qZ(Q,X,$,Z);if(!f(X)||!f(Q))return X;return F8(Q,X,Y,Z)}function qZ(Q,X,Y,Z){if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(Q)&&!Array.isArray(X))return X;if(Array.isArray(X)&&Array.isArray(Q))switch(Y){case"replace":return X;case"concat":return K8(Q,X);case"smart":return j8(Q,X,Z);default:return X}return X}function K8(Q,X){let Y=[...X];for(let Z of Q)if(!Y.some(($)=>bX($,Z)))Y.push(Z);return Y}function j8(Q,X,Y){if(X.length===0)return Q;if(Q.length===0)return X;if(f(X[0])&&f(Q[0]))return I8(Q,X,Y);if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}function I8(Q,X,Y){let Z=[...X];for(let $ of Q){if(!f($)){Z.push($);continue}let H=["id","name","key","path","type"],U=!1;for(let G of H)if(G in $){if(Z.find((_)=>f(_)&&(G in _)&&_[G]===$[G])){U=!0;break}}if(!U)Z.push($)}return Z}function F8(Q,X,Y,Z){let $=X;if(f($)&&Z.has($))return Z.get($);let H={...Q};if(f($))Z.set($,H);for(let U in $){if(!Object.prototype.hasOwnProperty.call($,U))continue;let G=$[U],J=H[U];if(Y.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){H[U]=G;continue}if(f(G)&&f(J))H[U]=_Z(J,G,Y,Z);else if(Array.isArray(G)||Array.isArray(J))H[U]=qZ(J,G,Y.arrayMergeMode||"smart",Z);else H[U]=G}return H}function WZ(Q,X,Y="replace"){return L8(Q,X,{arrayMergeMode:Y==="replace"?"replace":"smart",skipNullish:!0})}function bX(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!bX(Q[Y],X[Y]))return!1;return!0}if(f(Q)&&f(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!bX(Q[$],X[$]))return!1}return!0}return!1}function f(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}class AZ{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(Q,X,Y={}){let{arrayStrategy:Z="replace",useCache:$=!0,cacheTtl:H,trackPerformance:U=!0,verbose:G=!1}=Y;if($){let _=fQ.getWithFileCheck("file",Q);if(_){if(G)console.log(`Configuration loaded from cache: ${Q}`);return _}}let J=async()=>{if(!kQ(Q))return null;try{let _=`?t=${Date.now()}`,q=await import(Q+_),W=q.default||q,z="default"in q,A=Object.keys(q).length>0;if(!z&&!A)throw new rQ(Q,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof W!=="object"||W===null||Array.isArray(W))throw new rQ(Q,Error("Configuration must export a valid object"),"unknown");let K={config:WZ(X,W,Z),source:{type:"file",path:Q,priority:100,timestamp:new Date}};if($)fQ.setWithFileCheck("file",K,Q,H);return K}catch(_){throw _ instanceof Error?BQ.configLoad(Q,_):BQ.configLoad(Q,Error(String(_)))}};if(U)return yX.track("loadFromPath",J,{path:Q});return J()}async tryLoadFromPaths(Q,X,Y={}){for(let Z of Q)try{let $=await this.loadFromPath(Z,X,Y);if($)return $}catch($){if($ instanceof Error&&$.name==="ConfigLoadError")throw $;if(Y.verbose)console.warn(`Failed to load config from ${Z}:`,$)}return null}generateConfigPaths(Q,X,Y){let Z=this.generateNamePatterns(Q,Y),$=[];for(let H of Z)for(let U of this.extensions)$.push(FX(X,`${H}${U}`));return $}generateNamePatterns(Q,X){let Y=[];if(Y.push("config",".config"),Q)Y.push(Q,`.${Q}.config`,`${Q}.config`,`.${Q}`);let Z=X===void 0?[]:Array.isArray(X)?X:[X];for(let H of Z){if(!H)continue;if(Y.push(H,`.${H}.config`,`${H}.config`,`.${H}`),Q)Y.push(`${Q}.${H}.config`,`.${Q}.${H}.config`)}let $=new Set;return Y.filter((H)=>{if(!H||$.has(H))return!1;return $.add(H),!0})}checkFileAccess(Q){return w8(async()=>{return kQ(Q)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(Q,X,Y){let Z=[];if(!kQ(Q))return Z;if(X||Y){let $=this.generateNamePatterns(X||"",Y);for(let H of $)for(let U of this.extensions){let G=FX(Q,`${H}${U}`);if(await this.checkFileAccess(G))Z.push(G)}}else try{let{readdirSync:$}=await import("fs"),H=$(Q);for(let U of H)if(this.looksLikeConfigFile(U)){let G=FX(Q,U);if(await this.checkFileAccess(G))Z.push(G)}}catch{return[]}return Z}looksLikeConfigFile(Q){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((Y)=>Y.test(Q))}async validateConfigFile(Q){let X=[];try{if(!kQ(Q))return X.push("Configuration file does not exist"),X;let Y=await import(Q),Z=Y.default||Y;if(Z===void 0)X.push("Configuration file must export a default value or named exports");else if(typeof Z!=="object"||Z===null)X.push("Configuration must be an object");else if(Array.isArray(Z))X.push("Configuration cannot be an array at the root level");if(Q.endsWith(".json"))try{let{readFileSync:$}=await import("fs"),H=$(Q,"utf8");JSON.parse(H)}catch($){X.push(`Invalid JSON syntax: ${$}`)}}catch(Y){X.push(`Failed to load configuration file: ${Y}`)}return X}async getFileModificationTime(Q){try{let{statSync:X}=await import("fs");return X(Q).mtime}catch{return null}}async preloadConfigurations(Q,X={}){let Y=new Map;return await Promise.allSettled(Q.map(async(Z)=>{try{let $=await this.loadFromPath(Z,{},X);if($)Y.set(Z,$.config)}catch($){if(X.verbose)console.warn(`Failed to preload ${Z}:`,$)}})),Y}}var D8=/^https?:\/\//;class zZ{async validateConfiguration(Q,X,Y={}){let{stopOnFirstError:Z=!1,validateRequired:$=!0,validateTypes:H=!0,customRules:U=[],trackPerformance:G=!0,verbose:J=!1}=Y,_=async()=>{let q=[],W=[],z={stopOnFirstError:Z,validateRequired:$,validateTypes:H,customRules:U,trackPerformance:G,verbose:J};try{if(typeof X==="string")return await this.validateWithSchemaFile(Q,X,z);else if(Array.isArray(X))return this.validateWithRules(Q,[...X,...U],z);else return this.validateWithJSONSchema(Q,X,z)}catch(A){return q.push({path:"",message:`Validation failed: ${A}`,rule:"system"}),{isValid:!1,errors:q,warnings:W}}};if(G)return await yX.track("validateConfiguration",_);return _()}async validateWithSchemaFile(Q,X,Y){try{if(!M8(X))throw new aQ(X,[{path:"",message:"Schema file does not exist"}]);let Z=await import(X),$=Z.default||Z;if(Array.isArray($))return this.validateWithRules(Q,$,Y);else return this.validateWithJSONSchema(Q,$,Y)}catch(Z){throw new aQ(X,[{path:"",message:`Failed to load schema: ${Z}`}])}}validateWithJSONSchema(Q,X,Y){let Z=[],$=[];return this.validateObjectAgainstSchema(Q,X,"",Z,$,Y),{isValid:Z.length===0,errors:Z,warnings:$}}validateObjectAgainstSchema(Q,X,Y,Z,$,H){if(H.validateTypes&&X.type){let U=Array.isArray(Q)?"array":typeof Q,G=Array.isArray(X.type)?X.type:[X.type];if(!G.includes(U)){if(Z.push({path:Y,message:`Expected type ${G.join(" or ")}, got ${U}`,expected:G.join(" or "),actual:U,rule:"type"}),H.stopOnFirstError)return}}if(X.enum&&!X.enum.includes(Q)){if(Z.push({path:Y,message:`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"}),H.stopOnFirstError)return}if(typeof Q==="string"){if(X.minLength!==void 0&&Q.length<X.minLength)Z.push({path:Y,message:`String length must be at least ${X.minLength}`,expected:`>= ${X.minLength}`,actual:Q.length,rule:"minLength"});if(X.maxLength!==void 0&&Q.length>X.maxLength)Z.push({path:Y,message:`String length must not exceed ${X.maxLength}`,expected:`<= ${X.maxLength}`,actual:Q.length,rule:"maxLength"});if(X.pattern){if(!new RegExp(X.pattern).test(Q))Z.push({path:Y,message:`String does not match pattern ${X.pattern}`,expected:X.pattern,actual:Q,rule:"pattern"})}}if(typeof Q==="number"){if(X.minimum!==void 0&&Q<X.minimum)Z.push({path:Y,message:`Value must be at least ${X.minimum}`,expected:`>= ${X.minimum}`,actual:Q,rule:"minimum"});if(X.maximum!==void 0&&Q>X.maximum)Z.push({path:Y,message:`Value must not exceed ${X.maximum}`,expected:`<= ${X.maximum}`,actual:Q,rule:"maximum"})}if(Array.isArray(Q)&&X.items)for(let U=0;U<Q.length;U++){let G=Y?`${Y}[${U}]`:`[${U}]`;if(this.validateObjectAgainstSchema(Q[U],X.items,G,Z,$,H),H.stopOnFirstError&&Z.length>0)return}if(Q&&typeof Q==="object"&&!Array.isArray(Q)){let U=Q;if(H.validateRequired&&X.required){for(let G of X.required)if(!(G in U)){if(Z.push({path:Y?`${Y}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),H.stopOnFirstError)return}}if(X.properties){for(let[G,J]of Object.entries(X.properties))if(G in U){let _=Y?`${Y}.${G}`:G;if(this.validateObjectAgainstSchema(U[G],J,_,Z,$,H),H.stopOnFirstError&&Z.length>0)return}}if(X.additionalProperties===!1){let G=new Set(Object.keys(X.properties||{}));for(let J of Object.keys(U))if(!G.has(J))$.push({path:Y?`${Y}.${J}`:J,message:`Additional property '${J}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(Q,X,Y){let Z=[],$=[];for(let H of X)try{let U=this.getValueByPath(Q,H.path),G=this.validateWithRule(U,H,H.path);if(Z.push(...G),Y.stopOnFirstError&&Z.length>0)break}catch(U){Z.push({path:H.path,message:`Rule validation failed: ${U}`,rule:"system"})}return{isValid:Z.length===0,errors:Z,warnings:$}}validateWithRule(Q,X,Y){let Z=[];if(X.required&&(Q===void 0||Q===null))return Z.push({path:Y,message:X.message||`Property '${Y}' is required`,expected:"required",rule:"required"}),Z;if(Q===void 0||Q===null)return Z;if(X.type){let $=Array.isArray(Q)?"array":typeof Q;if($!==X.type)Z.push({path:Y,message:X.message||`Expected type ${X.type}, got ${$}`,expected:X.type,actual:$,rule:"type"})}if(X.min!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($<X.min)Z.push({path:Y,message:X.message||`Value must be at least ${X.min}`,expected:`>= ${X.min}`,actual:$,rule:"min"})}if(X.max!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($>X.max)Z.push({path:Y,message:X.message||`Value must not exceed ${X.max}`,expected:`<= ${X.max}`,actual:$,rule:"max"})}if(X.pattern&&typeof Q==="string"){if(!X.pattern.test(Q))Z.push({path:Y,message:X.message||`Value does not match pattern ${X.pattern}`,expected:X.pattern.toString(),actual:Q,rule:"pattern"})}if(X.enum&&!X.enum.includes(Q))Z.push({path:Y,message:X.message||`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"});if(X.validator){let $=X.validator(Q);if($)Z.push({path:Y,message:X.message||$,rule:"custom"})}return Z}getValueByPath(Q,X){if(!X)return Q;let Y=X.split("."),Z=Q;for(let $ of Y)if(Z&&typeof Z==="object"&&$ in Z)Z=Z[$];else return;return Z}generateRulesFromInterface(Q){let X=[],Y=Q.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let Z of Y){let[,$,H,U]=Z;X.push({path:$,required:!H,type:this.mapTypeScriptType(U)})}return X}mapTypeScriptType(Q){switch(Q.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:D8},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}var c=new YX("bunfig",{showTags:!0});function V8(Q){if(!Q)return"";let X=Array.isArray(Q)?Q.filter(Boolean):[Q];if(X.length===0)return"";if(X.length===1)return` or alias "${X[0]}"`;return` or aliases ${X.map((Y)=>`"${Y}"`).join(", ")}`}class BZ{fileLoader=new AZ;envProcessor=new cX;validator=new zZ;async loadConfig(Q){let X=Date.now(),{cache:Y,performance:Z,schema:$,validate:H,...U}=Q;try{if(Y?.enabled){let J=this.checkCache(U.name||"",U);if(J)return J}let G;try{G=await this.loadConfigurationStrategies(U,!0,Y)}catch(J){let _=U.__strictErrorHandling;if(J instanceof Error&&J.name==="ConfigNotFoundError"){if(_)throw J;G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`No configuration file found for "${U.name||"config"}", using defaults with environment variables`]}}else if(J instanceof Error&&J.name==="ConfigLoadError"){let q=J.message.includes("EACCES")||J.message.includes("EPERM")||J.message.includes("permission denied"),W=!q&&(J.message.includes("syntax")||J.message.includes("Expected")||J.message.includes("Unexpected")||J.message.includes("BuildMessage")||J.message.includes("errors building")),z=J.message.includes("Configuration must export a valid object")||J.message.includes("Configuration file is empty and exports nothing");if(_&&(z||q))throw J;if(W&&(!_||!z))G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!_)G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading error, using defaults: ${J.message}`]};else throw J}else G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${J instanceof Error?J.message:String(J)}`]}}if($||H)await this.validateConfiguration(G.config,$,H,U.name);if(Y?.enabled&&G)this.cacheResult(U.name||"",G,Y,U);if(Z?.enabled){let J={operation:"loadConfig",duration:Date.now()-X,configName:U.name,timestamp:new Date};if(Z.onMetrics)Z.onMetrics(J);if(Z.slowThreshold&&J.duration>Z.slowThreshold)c.warn(`Slow configuration loading detected: ${J.duration}ms for ${U.name}`);G.metrics=J}return G}catch(G){if(G instanceof Error&&G.name==="ConfigNotFoundError")throw G;let J=Date.now()-X;throw c.error(`Configuration loading failed after ${J}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies(Q,X=!1,Y){let{name:Z="",alias:$,cwd:H,configDir:U,defaultConfig:G,checkEnv:J=!0,arrayStrategy:_="replace",verbose:q=!1}=Q,W=H||eQ.cwd(),z=[],A=await this.loadLocalConfiguration(Z,$,W,U,G,_,q,J,Y);if(A)return z.push(...this.getLocalSearchPaths(Z,$,W,U)),this.finalizeResult(A,z,J,Z,q);let I=await this.loadHomeConfiguration(Z,$,G,_,q,J);if(I)return z.push(...this.getHomeSearchPaths(Z,$)),this.finalizeResult(I,z,J,Z,q);let B=await this.loadPackageJsonConfiguration(Z,$,W,G,_,q,J);if(B)return z.push(d(W,"package.json")),this.finalizeResult(B,z,J,Z,q);if(z.push(...this.getAllSearchPaths(Z,$,W,U)),X)throw BQ.configNotFound(Z,z,$);return{...await this.applyEnvironmentVariables(Z,G,J,q),warnings:[`No configuration file found for "${Z}"${V8($)}, using defaults with environment variables`]}}async loadLocalConfiguration(Q,X,Y,Z,$,H,U,G,J){let _=G?PQ(Q,$,U):$,q=this.getLocalDirectories(Y,Z);for(let W of q){if(U)c.info(`Searching for configuration in: ${W}`);let z=this.fileLoader.generateConfigPaths(Q,W,X),A=await this.fileLoader.tryLoadFromPaths(z,_,{arrayStrategy:H,verbose:U,cacheTtl:J?.ttl,useCache:!J?.ttl||J.ttl>100});if(A){if(U)c.success(`Configuration loaded from: ${A.source.path}`);return A}}return null}async loadHomeConfiguration(Q,X,Y,Z,$,H){if(!Q)return null;let U=H?PQ(Q,Y,$):Y,G=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()];for(let J of G){if($)c.info(`Checking home directory: ${J}`);let _=this.fileLoader.generateConfigPaths(Q,J,X),q=await this.fileLoader.tryLoadFromPaths(_,U,{arrayStrategy:Z,verbose:$});if(q){if($)c.success(`Configuration loaded from home directory: ${q.source.path}`);return q}}return null}async loadPackageJsonConfiguration(Q,X,Y,Z,$,H,U){let G=U?PQ(Q,Z,H):Z;try{let J=d(Y,"package.json");if(!LZ(J))return null;let _={};try{_=JSON.parse(KZ(J,"utf8"))}catch(z){if(H)c.warn("Failed to parse package.json:",[z instanceof Error?z:Error(String(z))]);return null}let q=_[Q],W=Q;if(!q&&X){let z=Array.isArray(X)?X:[X];for(let A of z){if(!A)continue;if(_[A]){q=_[A],W=A;break}}}if(q&&typeof q==="object"&&!Array.isArray(q)){if(H)c.success(`Configuration loaded from package.json: ${W}`);return{config:WZ(G,q,$),source:{type:"package.json",path:J,priority:30,timestamp:new Date}}}}catch(J){if(H)c.warn("Failed to load package.json:",[J instanceof Error?J:Error(String(J))])}return null}async applyEnvironmentVariables(Q,X,Y,Z){if(!Y||!Q||typeof X!=="object"||X===null||Array.isArray(X))return{config:X,source:{type:"default",priority:10,timestamp:new Date}};return{config:PQ(Q,X,Z),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(Q,X,Y,Z,$){return{config:Q.config,source:Q.source,path:Q.source.path}}async validateConfiguration(Q,X,Y,Z){let $=[];if(Y){let H=Y(Q);if(H)$.push(...H)}if(X){let H=await this.validator.validateConfiguration(Q,X);if(!H.isValid)$.push(...H.errors.map((U)=>U.path?`${U.path}: ${U.message}`:U.message))}if($.length>0)throw BQ.configValidation(Z||"unknown",$,Z)}checkCache(Q,X){let Y=this.generateCacheKey(Q,X);return fQ.get(Y)||null}cacheResult(Q,X,Y,Z){let $=this.generateCacheKey(Q,Z);fQ.set($,X,void 0,Y.ttl)}generateCacheKey(Q,X){let Y=[Q];if(X.alias){let Z=Array.isArray(X.alias)?X.alias.join(","):X.alias;Y.push(`alias:${Z}`)}if(X.cwd)Y.push(`cwd:${X.cwd}`);if(X.configDir)Y.push(`configDir:${X.configDir}`);if("checkEnv"in X)Y.push(`checkEnv:${X.checkEnv}`);return Y.join("|")}getLocalDirectories(Q,X){return Array.from(new Set([Q,d(Q,"config"),d(Q,".config"),X?d(Q,X):void 0].filter(Boolean)))}getAllSearchPaths(Q,X,Y,Z){let $=[];return $.push(...this.getLocalSearchPaths(Q,X,Y,Z)),$.push(...this.getHomeSearchPaths(Q,X)),$.push(d(Y,"package.json")),$}getLocalSearchPaths(Q,X,Y,Z){let $=this.getLocalDirectories(Y,Z),H=[];for(let U of $)H.push(...this.fileLoader.generateConfigPaths(Q,U,X));return H}getHomeSearchPaths(Q,X){if(!Q)return[];let Y=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()],Z=[];for(let $ of Y)Z.push(...this.fileLoader.generateConfigPaths(Q,$,X));return Z}async loadConfigWithResult(Q){return this.loadConfig(Q)}}var MX=new BZ;async function RZ(Q){let X="defaultConfig"in Q&&Q.defaultConfig!==void 0?Q.defaultConfig:{},Y="cache"in Q||"performance"in Q||"schema"in Q||"validate"in Q;try{let Z;if(Y)Z=await MX.loadConfig(Q);else Z=await MX.loadConfig({...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}});return Z?.config??X}catch(Z){let $=Z instanceof Error?Z.name:"UnknownError",H=Z instanceof Error?Z.message:String(Z);if(!($==="ConfigNotFoundError"||$==="ConfigLoadError"||$==="ConfigValidationError"||H.includes("config"))&&Q.verbose)c.warn("Unexpected error loading config, using defaults:",[Z instanceof Error?Z:Error(String(Z))]);let G=Y?{...Q,defaultConfig:X}:{...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in Q?Q.checkEnv!==!1:!0)return(await MX.applyEnvironmentVariables(G.name||"",X,!0,G.verbose||!1))?.config??X;return X}}function PQ(Q,X,Y=!1){let Z=new cX,$=Q.toUpperCase().replace(/[^A-Z0-9]/g,"_");function H(U,G=[]){let J={...U};for(let[_,q]of Object.entries(U)){let W=[...G,_],z=[`${$}_${W.join("_").toUpperCase()}`,`${$}_${W.map((B)=>B.toUpperCase()).join("")}`,`${$}_${W.map((B)=>B.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],A,I;for(let B of z)if(A=eQ.env[B],A!==void 0){I=B;break}if(A!==void 0&&I)if(typeof q==="boolean")J[_]=["true","1","yes"].includes(A.toLowerCase());else if(typeof q==="number"){let B=Number(A);if(!Number.isNaN(B))J[_]=B}else if(Array.isArray(q))try{J[_]=JSON.parse(A)}catch{J[_]=A.split(",").map((B)=>B.trim())}else J[_]=A;else if(q&&typeof q==="object"&&!Array.isArray(q))J[_]=H(q,W)}return J}return H(X)}var J$=d(eQ.cwd(),"config"),G$=d(eQ.cwd(),"src/generated");var S8=["code-style","lint"],wZ={ignores:["**/node_modules/**","**/.pnpm/**","**/.yarn/**","**/dist/**","**/build/**","**/out/**","**/.output/**","**/.next/**","**/.nuxt/**","**/.vite/**","**/.turbo/**","**/.cache/**","**/coverage/**","**/vendor/**","**/pantry/**","**/tmp/**","**/.git/**","**/.idea/**","**/.vscode/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/*.test.ts","**/*.spec.ts","**/.bunpress/**","**/.vitepress/cache/**","**/*.lock","**/package-lock.json","**/pnpm-lock.yaml"],lint:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],reporter:"stylish",cache:!1,maxWarnings:-1},format:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],trimTrailingWhitespace:!0,maxConsecutiveBlankLines:1,finalNewline:"one",indent:2,indentStyle:"spaces",quotes:"single",semi:!1},rules:{noDebugger:"error",noConsole:"warn"},pluginRules:{"style/brace-style":"warn","style/curly":"off","style/if-newline":"off","style/max-statements-per-line":"warn","pickier/import-dedupe":"warn","pickier/no-import-node-modules-by-path":"error","pickier/no-import-dist":"error","pickier/prefer-const":"error","pickier/prefer-template":"warn","pickier/no-unused-vars":"error","pickier/sort-tailwind-classes":"warn","regexp/no-unused-capturing-group":"error","regexp/no-super-linear-backtracking":"error","regexp/no-useless-lazy":"error","ts/no-top-level-await":"error","ts/member-delimiter-style":"off","ts/type-annotation-spacing":"off","style/comma-dangle":"off","style/keyword-spacing":"off","style/arrow-spacing":"off","style/space-infix-ops":"off","style/object-curly-spacing":"off","style/spaced-comment":"off","style/block-spacing":"off","style/space-before-blocks":"off","style/comma-spacing":"off","style/semi-spacing":"off","style/rest-spread-spacing":"off","style/key-spacing":"off","style/computed-property-spacing":"off","style/array-bracket-spacing":"off","style/space-in-parens":"off","style/template-curly-spacing":"off","style/space-unary-ops":"off","style/switch-colon-spacing":"off","style/arrow-parens":"off","style/space-before-function-paren":"off","style/quote-props":"off","style/no-floating-decimal":"off","style/new-parens":"off","style/no-extra-parens":"off","style/wrap-iife":"off","style/comma-style":"off","style/dot-location":"off","style/operator-linebreak":"off","style/multiline-ternary":"off","style/padded-blocks":"off","style/lines-between-class-members":"off","style/no-tabs":"off","style/no-mixed-spaces-and-tabs":"off","style/generator-star-spacing":"off","style/yield-star-spacing":"off","style/function-call-spacing":"off","style/template-tag-spacing":"off","style/no-whitespace-before-property":"off","style/no-mixed-operators":"off","style/indent-binary-ops":"off","ts/type-generic-spacing":"off","ts/type-named-tuple-spacing":"off","markdown/heading-increment":"warn","markdown/heading-style":"warn","markdown/no-missing-space-atx":"error","markdown/no-multiple-space-atx":"error","markdown/no-missing-space-closed-atx":"error","markdown/no-multiple-space-closed-atx":"error","markdown/blanks-around-headings":"warn","markdown/heading-start-left":"warn","markdown/no-duplicate-heading":"warn","markdown/single-title":"warn","markdown/no-trailing-punctuation":"warn","markdown/ul-style":"warn","markdown/list-indent":"error","markdown/ul-indent":"warn","markdown/ol-prefix":"warn","markdown/list-marker-space":"error","markdown/blanks-around-lists":"warn","markdown/no-trailing-spaces":"error","markdown/no-hard-tabs":"error","markdown/no-multiple-blanks":"warn","markdown/no-multiple-space-blockquote":"error","markdown/no-blanks-blockquote":"warn","markdown/blanks-around-fences":"warn","markdown/single-trailing-newline":"error","markdown/blanks-around-tables":"warn","markdown/no-reversed-links":"error","markdown/no-bare-urls":"warn","markdown/no-space-in-links":"error","markdown/no-empty-links":"error","markdown/link-fragments":"warn","markdown/reference-links-images":"warn","markdown/link-image-reference-definitions":"warn","markdown/link-image-style":"warn","markdown/descriptive-link-text":"warn","markdown/line-length":"off","markdown/commands-show-output":"warn","markdown/fenced-code-language":"warn","markdown/code-block-style":"off","markdown/code-fence-style":"warn","markdown/no-emphasis-as-heading":"warn","markdown/no-space-in-emphasis":"warn","markdown/no-space-in-code":"warn","markdown/emphasis-style":"warn","markdown/strong-style":"warn","markdown/no-inline-html":"off","markdown/hr-style":"warn","markdown/first-line-heading":"off","markdown/required-headings":"off","markdown/proper-names":"off","markdown/no-alt-text":"warn","markdown/table-pipe-style":"warn","markdown/table-column-count":"warn","markdown/table-column-style":"warn","lockfile/validate-host":["warn",{allowedHosts:["npm","yarn"]}],"lockfile/validate-https":"error","lockfile/validate-integrity":["warn",{requiredAlgorithm:"sha512"}],"lockfile/validate-package-names":"error","lockfile/validate-scheme":["error",{allowedSchemes:["https:","git+https:","git+ssh:"]}],"publint/exports-types-should-be-first":"error","publint/exports-default-should-be-last":"error","publint/exports-module-should-precede-require":"error","publint/exports-value-invalid":"error","publint/imports-key-invalid":"error","publint/imports-value-invalid":"error","publint/imports-default-should-be-last":"error","publint/imports-module-should-precede-require":"error","publint/use-type":"warn","publint/deprecated-field-jsnext":"warn","publint/field-invalid-value-type":"error","publint/local-dependency":"error","publint/has-module-but-no-exports":"warn","publint/exports-missing-root-entrypoint":"warn","publint/exports-fallback-array-use":"warn","publint/file-does-not-exist":"warn","publint/file-invalid-format":"warn","publint/module-should-be-esm":"error","publint/bin-file-not-executable":"error","publint/exports-module-should-be-esm":"error","shell/command-substitution":"error","shell/quote-variables":"warn","shell/no-cd-without-check":"warn","shell/no-eval":"error","shell/no-useless-cat":"warn","shell/shebang":"warn","shell/indent":"warn","shell/function-style":"warn","shell/operator-spacing":"warn","shell/keyword-spacing":"warn","shell/no-trailing-semicolons":"warn","shell/no-trailing-whitespace":"error","shell/prefer-double-brackets":"warn","shell/set-options":"off","shell/prefer-printf":"warn","shell/consistent-case-terminators":"warn","shell/no-broken-redirect":"error","shell/heredoc-indent":"warn","shell/no-ls-parsing":"warn","shell/no-variable-in-single-quotes":"warn","shell/no-exit-in-subshell":"warn","spell/check":"off","spell/check-comments":"off","spell/check-markdown":"off"},verbose:!0},lX=null;async function W$(){if(!lX)lX=await RZ({name:"pickier",alias:[...S8],defaultConfig:wZ});return lX}var A$=wZ;
|
|
61
|
+
`;return Y}}function L8(Q,X,Y={}){return _Z(Q,X,Y,new WeakMap)}function _Z(Q,X,Y,Z){let{arrayMergeMode:$="replace",skipNullish:H=!1,customMerger:U}=Y;if(X===null||X===void 0)return H?Q:X;if(U){let G=U(Q,X);if(G!==void 0)return G}if(Array.isArray(X)||Array.isArray(Q))return qZ(Q,X,$,Z);if(!f(X)||!f(Q))return X;return F8(Q,X,Y,Z)}function qZ(Q,X,Y,Z){if(Array.isArray(X)&&!Array.isArray(Q))return X;if(Array.isArray(Q)&&!Array.isArray(X))return X;if(Array.isArray(X)&&Array.isArray(Q))switch(Y){case"replace":return X;case"concat":return K8(Q,X);case"smart":return j8(Q,X,Z);default:return X}return X}function K8(Q,X){let Y=[...X];for(let Z of Q)if(!Y.some(($)=>bX($,Z)))Y.push(Z);return Y}function j8(Q,X,Y){if(X.length===0)return Q;if(Q.length===0)return X;if(f(X[0])&&f(Q[0]))return I8(Q,X,Y);if(X.every((Z)=>typeof Z==="string")&&Q.every((Z)=>typeof Z==="string")){let Z=[...X];for(let $ of Q)if(!Z.includes($))Z.push($);return Z}return X}function I8(Q,X,Y){let Z=[...X];for(let $ of Q){if(!f($)){Z.push($);continue}let H=["id","name","key","path","type"],U=!1;for(let G of H)if(G in $){if(Z.find((_)=>f(_)&&(G in _)&&_[G]===$[G])){U=!0;break}}if(!U)Z.push($)}return Z}function F8(Q,X,Y,Z){let $=X;if(f($)&&Z.has($))return Z.get($);let H={...Q};if(f($))Z.set($,H);for(let U in $){if(!Object.prototype.hasOwnProperty.call($,U))continue;let G=$[U],J=H[U];if(Y.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){H[U]=G;continue}if(f(G)&&f(J))H[U]=_Z(J,G,Y,Z);else if(Array.isArray(G)||Array.isArray(J))H[U]=qZ(J,G,Y.arrayMergeMode||"smart",Z);else H[U]=G}return H}function WZ(Q,X,Y="replace"){return L8(Q,X,{arrayMergeMode:Y==="replace"?"replace":"smart",skipNullish:!0})}function bX(Q,X){if(Q===X)return!0;if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return!1;for(let Y=0;Y<Q.length;Y++)if(!bX(Q[Y],X[Y]))return!1;return!0}if(f(Q)&&f(X)){let Y=Object.keys(Q),Z=Object.keys(X);if(Y.length!==Z.length)return!1;for(let $ of Y){if(!Object.prototype.hasOwnProperty.call(X,$))return!1;if(!bX(Q[$],X[$]))return!1}return!0}return!1}function f(Q){return Boolean(Q&&typeof Q==="object"&&!Array.isArray(Q))}class AZ{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(Q,X,Y={}){let{arrayStrategy:Z="replace",useCache:$=!0,cacheTtl:H,trackPerformance:U=!0,verbose:G=!1}=Y;if($){let _=fQ.getWithFileCheck("file",Q);if(_){if(G)console.log(`Configuration loaded from cache: ${Q}`);return _}}let J=async()=>{if(!kQ(Q))return null;try{let _=`?t=${Date.now()}`,q=await import(Q+_),W=q.default||q,z="default"in q,A=Object.keys(q).length>0;if(!z&&!A)throw new rQ(Q,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof W!=="object"||W===null||Array.isArray(W))throw new rQ(Q,Error("Configuration must export a valid object"),"unknown");let K={config:WZ(X,W,Z),source:{type:"file",path:Q,priority:100,timestamp:new Date}};if($)fQ.setWithFileCheck("file",K,Q,H);return K}catch(_){throw _ instanceof Error?BQ.configLoad(Q,_):BQ.configLoad(Q,Error(String(_)))}};if(U)return yX.track("loadFromPath",J,{path:Q});return J()}async tryLoadFromPaths(Q,X,Y={}){for(let Z of Q)try{let $=await this.loadFromPath(Z,X,Y);if($)return $}catch($){if($ instanceof Error&&$.name==="ConfigLoadError")throw $;if(Y.verbose)console.warn(`Failed to load config from ${Z}:`,$)}return null}generateConfigPaths(Q,X,Y){let Z=this.generateNamePatterns(Q,Y),$=[];for(let H of Z)for(let U of this.extensions)$.push(FX(X,`${H}${U}`));return $}generateNamePatterns(Q,X){let Y=[];if(Y.push("config",".config"),Q)Y.push(Q,`.${Q}.config`,`${Q}.config`,`.${Q}`);let Z=X===void 0?[]:Array.isArray(X)?X:[X];for(let H of Z){if(!H)continue;if(Y.push(H,`.${H}.config`,`${H}.config`,`.${H}`),Q)Y.push(`${Q}.${H}.config`,`.${Q}.${H}.config`)}let $=new Set;return Y.filter((H)=>{if(!H||$.has(H))return!1;return $.add(H),!0})}checkFileAccess(Q){return w8(async()=>{return kQ(Q)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(Q,X,Y){let Z=[];if(!kQ(Q))return Z;if(X||Y){let $=this.generateNamePatterns(X||"",Y);for(let H of $)for(let U of this.extensions){let G=FX(Q,`${H}${U}`);if(await this.checkFileAccess(G))Z.push(G)}}else try{let{readdirSync:$}=await import("fs"),H=$(Q);for(let U of H)if(this.looksLikeConfigFile(U)){let G=FX(Q,U);if(await this.checkFileAccess(G))Z.push(G)}}catch{return[]}return Z}looksLikeConfigFile(Q){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((Y)=>Y.test(Q))}async validateConfigFile(Q){let X=[];try{if(!kQ(Q))return X.push("Configuration file does not exist"),X;let Y=await import(Q),Z=Y.default||Y;if(Z===void 0)X.push("Configuration file must export a default value or named exports");else if(typeof Z!=="object"||Z===null)X.push("Configuration must be an object");else if(Array.isArray(Z))X.push("Configuration cannot be an array at the root level");if(Q.endsWith(".json"))try{let{readFileSync:$}=await import("fs"),H=$(Q,"utf8");JSON.parse(H)}catch($){X.push(`Invalid JSON syntax: ${$}`)}}catch(Y){X.push(`Failed to load configuration file: ${Y}`)}return X}async getFileModificationTime(Q){try{let{statSync:X}=await import("fs");return X(Q).mtime}catch{return null}}async preloadConfigurations(Q,X={}){let Y=new Map;return await Promise.allSettled(Q.map(async(Z)=>{try{let $=await this.loadFromPath(Z,{},X);if($)Y.set(Z,$.config)}catch($){if(X.verbose)console.warn(`Failed to preload ${Z}:`,$)}})),Y}}var D8=/^https?:\/\//;class zZ{async validateConfiguration(Q,X,Y={}){let{stopOnFirstError:Z=!1,validateRequired:$=!0,validateTypes:H=!0,customRules:U=[],trackPerformance:G=!0,verbose:J=!1}=Y,_=async()=>{let q=[],W=[],z={stopOnFirstError:Z,validateRequired:$,validateTypes:H,customRules:U,trackPerformance:G,verbose:J};try{if(typeof X==="string")return await this.validateWithSchemaFile(Q,X,z);else if(Array.isArray(X))return this.validateWithRules(Q,[...X,...U],z);else return this.validateWithJSONSchema(Q,X,z)}catch(A){return q.push({path:"",message:`Validation failed: ${A}`,rule:"system"}),{isValid:!1,errors:q,warnings:W}}};if(G)return await yX.track("validateConfiguration",_);return _()}async validateWithSchemaFile(Q,X,Y){try{if(!M8(X))throw new aQ(X,[{path:"",message:"Schema file does not exist"}]);let Z=await import(X),$=Z.default||Z;if(Array.isArray($))return this.validateWithRules(Q,$,Y);else return this.validateWithJSONSchema(Q,$,Y)}catch(Z){throw new aQ(X,[{path:"",message:`Failed to load schema: ${Z}`}])}}validateWithJSONSchema(Q,X,Y){let Z=[],$=[];return this.validateObjectAgainstSchema(Q,X,"",Z,$,Y),{isValid:Z.length===0,errors:Z,warnings:$}}validateObjectAgainstSchema(Q,X,Y,Z,$,H){if(H.validateTypes&&X.type){let U=Array.isArray(Q)?"array":typeof Q,G=Array.isArray(X.type)?X.type:[X.type];if(!G.includes(U)){if(Z.push({path:Y,message:`Expected type ${G.join(" or ")}, got ${U}`,expected:G.join(" or "),actual:U,rule:"type"}),H.stopOnFirstError)return}}if(X.enum&&!X.enum.includes(Q)){if(Z.push({path:Y,message:`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"}),H.stopOnFirstError)return}if(typeof Q==="string"){if(X.minLength!==void 0&&Q.length<X.minLength)Z.push({path:Y,message:`String length must be at least ${X.minLength}`,expected:`>= ${X.minLength}`,actual:Q.length,rule:"minLength"});if(X.maxLength!==void 0&&Q.length>X.maxLength)Z.push({path:Y,message:`String length must not exceed ${X.maxLength}`,expected:`<= ${X.maxLength}`,actual:Q.length,rule:"maxLength"});if(X.pattern){if(!new RegExp(X.pattern).test(Q))Z.push({path:Y,message:`String does not match pattern ${X.pattern}`,expected:X.pattern,actual:Q,rule:"pattern"})}}if(typeof Q==="number"){if(X.minimum!==void 0&&Q<X.minimum)Z.push({path:Y,message:`Value must be at least ${X.minimum}`,expected:`>= ${X.minimum}`,actual:Q,rule:"minimum"});if(X.maximum!==void 0&&Q>X.maximum)Z.push({path:Y,message:`Value must not exceed ${X.maximum}`,expected:`<= ${X.maximum}`,actual:Q,rule:"maximum"})}if(Array.isArray(Q)&&X.items)for(let U=0;U<Q.length;U++){let G=Y?`${Y}[${U}]`:`[${U}]`;if(this.validateObjectAgainstSchema(Q[U],X.items,G,Z,$,H),H.stopOnFirstError&&Z.length>0)return}if(Q&&typeof Q==="object"&&!Array.isArray(Q)){let U=Q;if(H.validateRequired&&X.required){for(let G of X.required)if(!(G in U)){if(Z.push({path:Y?`${Y}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),H.stopOnFirstError)return}}if(X.properties){for(let[G,J]of Object.entries(X.properties))if(G in U){let _=Y?`${Y}.${G}`:G;if(this.validateObjectAgainstSchema(U[G],J,_,Z,$,H),H.stopOnFirstError&&Z.length>0)return}}if(X.additionalProperties===!1){let G=new Set(Object.keys(X.properties||{}));for(let J of Object.keys(U))if(!G.has(J))$.push({path:Y?`${Y}.${J}`:J,message:`Additional property '${J}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(Q,X,Y){let Z=[],$=[];for(let H of X)try{let U=this.getValueByPath(Q,H.path),G=this.validateWithRule(U,H,H.path);if(Z.push(...G),Y.stopOnFirstError&&Z.length>0)break}catch(U){Z.push({path:H.path,message:`Rule validation failed: ${U}`,rule:"system"})}return{isValid:Z.length===0,errors:Z,warnings:$}}validateWithRule(Q,X,Y){let Z=[];if(X.required&&(Q===void 0||Q===null))return Z.push({path:Y,message:X.message||`Property '${Y}' is required`,expected:"required",rule:"required"}),Z;if(Q===void 0||Q===null)return Z;if(X.type){let $=Array.isArray(Q)?"array":typeof Q;if($!==X.type)Z.push({path:Y,message:X.message||`Expected type ${X.type}, got ${$}`,expected:X.type,actual:$,rule:"type"})}if(X.min!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($<X.min)Z.push({path:Y,message:X.message||`Value must be at least ${X.min}`,expected:`>= ${X.min}`,actual:$,rule:"min"})}if(X.max!==void 0){let $=Array.isArray(Q)?Q.length:typeof Q==="string"?Q.length:typeof Q==="number"?Q:0;if($>X.max)Z.push({path:Y,message:X.message||`Value must not exceed ${X.max}`,expected:`<= ${X.max}`,actual:$,rule:"max"})}if(X.pattern&&typeof Q==="string"){if(!X.pattern.test(Q))Z.push({path:Y,message:X.message||`Value does not match pattern ${X.pattern}`,expected:X.pattern.toString(),actual:Q,rule:"pattern"})}if(X.enum&&!X.enum.includes(Q))Z.push({path:Y,message:X.message||`Value must be one of: ${X.enum.join(", ")}`,expected:X.enum.join(", "),actual:Q,rule:"enum"});if(X.validator){let $=X.validator(Q);if($)Z.push({path:Y,message:X.message||$,rule:"custom"})}return Z}getValueByPath(Q,X){if(!X)return Q;let Y=X.split("."),Z=Q;for(let $ of Y)if(Z&&typeof Z==="object"&&$ in Z)Z=Z[$];else return;return Z}generateRulesFromInterface(Q){let X=[],Y=Q.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let Z of Y){let[,$,H,U]=Z;X.push({path:$,required:!H,type:this.mapTypeScriptType(U)})}return X}mapTypeScriptType(Q){switch(Q.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:D8},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}var c=new YX("bunfig",{showTags:!0});function V8(Q){if(!Q)return"";let X=Array.isArray(Q)?Q.filter(Boolean):[Q];if(X.length===0)return"";if(X.length===1)return` or alias "${X[0]}"`;return` or aliases ${X.map((Y)=>`"${Y}"`).join(", ")}`}class BZ{fileLoader=new AZ;envProcessor=new cX;validator=new zZ;async loadConfig(Q){let X=Date.now(),{cache:Y,performance:Z,schema:$,validate:H,...U}=Q;try{if(Y?.enabled){let J=this.checkCache(U.name||"",U);if(J)return J}let G;try{G=await this.loadConfigurationStrategies(U,!0,Y)}catch(J){let _=U.__strictErrorHandling;if(J instanceof Error&&J.name==="ConfigNotFoundError"){if(_)throw J;G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`No configuration file found for "${U.name||"config"}", using defaults with environment variables`]}}else if(J instanceof Error&&J.name==="ConfigLoadError"){let q=J.message.includes("EACCES")||J.message.includes("EPERM")||J.message.includes("permission denied"),W=!q&&(J.message.includes("syntax")||J.message.includes("Expected")||J.message.includes("Unexpected")||J.message.includes("BuildMessage")||J.message.includes("errors building")),z=J.message.includes("Configuration must export a valid object")||J.message.includes("Configuration file is empty and exports nothing");if(_&&(z||q))throw J;if(W&&(!_||!z))G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!_)G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading error, using defaults: ${J.message}`]};else throw J}else G={...await this.applyEnvironmentVariables(U.name||"",U.defaultConfig,U.checkEnv!==!1,U.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${J instanceof Error?J.message:String(J)}`]}}if($||H)await this.validateConfiguration(G.config,$,H,U.name);if(Y?.enabled&&G)this.cacheResult(U.name||"",G,Y,U);if(Z?.enabled){let J={operation:"loadConfig",duration:Date.now()-X,configName:U.name,timestamp:new Date};if(Z.onMetrics)Z.onMetrics(J);if(Z.slowThreshold&&J.duration>Z.slowThreshold)c.warn(`Slow configuration loading detected: ${J.duration}ms for ${U.name}`);G.metrics=J}return G}catch(G){if(G instanceof Error&&G.name==="ConfigNotFoundError")throw G;let J=Date.now()-X;throw c.error(`Configuration loading failed after ${J}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies(Q,X=!1,Y){let{name:Z="",alias:$,cwd:H,configDir:U,defaultConfig:G,checkEnv:J=!0,arrayStrategy:_="replace",verbose:q=!1}=Q,W=H||eQ.cwd(),z=[],A=await this.loadLocalConfiguration(Z,$,W,U,G,_,q,J,Y);if(A)return z.push(...this.getLocalSearchPaths(Z,$,W,U)),this.finalizeResult(A,z,J,Z,q);let I=await this.loadHomeConfiguration(Z,$,G,_,q,J);if(I)return z.push(...this.getHomeSearchPaths(Z,$)),this.finalizeResult(I,z,J,Z,q);let B=await this.loadPackageJsonConfiguration(Z,$,W,G,_,q,J);if(B)return z.push(d(W,"package.json")),this.finalizeResult(B,z,J,Z,q);if(z.push(...this.getAllSearchPaths(Z,$,W,U)),X)throw BQ.configNotFound(Z,z,$);return{...await this.applyEnvironmentVariables(Z,G,J,q),warnings:[`No configuration file found for "${Z}"${V8($)}, using defaults with environment variables`]}}async loadLocalConfiguration(Q,X,Y,Z,$,H,U,G,J){let _=G?PQ(Q,$,U):$,q=this.getLocalDirectories(Y,Z);for(let W of q){if(U)c.info(`Searching for configuration in: ${W}`);let z=this.fileLoader.generateConfigPaths(Q,W,X),A=await this.fileLoader.tryLoadFromPaths(z,_,{arrayStrategy:H,verbose:U,cacheTtl:J?.ttl,useCache:!J?.ttl||J.ttl>100});if(A){if(U)c.success(`Configuration loaded from: ${A.source.path}`);return A}}return null}async loadHomeConfiguration(Q,X,Y,Z,$,H){if(!Q)return null;let U=H?PQ(Q,Y,$):Y,G=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()];for(let J of G){if($)c.info(`Checking home directory: ${J}`);let _=this.fileLoader.generateConfigPaths(Q,J,X),q=await this.fileLoader.tryLoadFromPaths(_,U,{arrayStrategy:Z,verbose:$});if(q){if($)c.success(`Configuration loaded from home directory: ${q.source.path}`);return q}}return null}async loadPackageJsonConfiguration(Q,X,Y,Z,$,H,U){let G=U?PQ(Q,Z,H):Z;try{let J=d(Y,"package.json");if(!LZ(J))return null;let _={};try{_=JSON.parse(KZ(J,"utf8"))}catch(z){if(H)c.warn("Failed to parse package.json:",[z instanceof Error?z:Error(String(z))]);return null}let q=_[Q],W=Q;if(!q&&X){let z=Array.isArray(X)?X:[X];for(let A of z){if(!A)continue;if(_[A]){q=_[A],W=A;break}}}if(q&&typeof q==="object"&&!Array.isArray(q)){if(H)c.success(`Configuration loaded from package.json: ${W}`);return{config:WZ(G,q,$),source:{type:"package.json",path:J,priority:30,timestamp:new Date}}}}catch(J){if(H)c.warn("Failed to load package.json:",[J instanceof Error?J:Error(String(J))])}return null}async applyEnvironmentVariables(Q,X,Y,Z){if(!Y||!Q||typeof X!=="object"||X===null||Array.isArray(X))return{config:X,source:{type:"default",priority:10,timestamp:new Date}};return{config:PQ(Q,X,Z),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(Q,X,Y,Z,$){return{config:Q.config,source:Q.source,path:Q.source.path}}async validateConfiguration(Q,X,Y,Z){let $=[];if(Y){let H=Y(Q);if(H)$.push(...H)}if(X){let H=await this.validator.validateConfiguration(Q,X);if(!H.isValid)$.push(...H.errors.map((U)=>U.path?`${U.path}: ${U.message}`:U.message))}if($.length>0)throw BQ.configValidation(Z||"unknown",$,Z)}checkCache(Q,X){let Y=this.generateCacheKey(Q,X);return fQ.get(Y)||null}cacheResult(Q,X,Y,Z){let $=this.generateCacheKey(Q,Z);fQ.set($,X,void 0,Y.ttl)}generateCacheKey(Q,X){let Y=[Q];if(X.alias){let Z=Array.isArray(X.alias)?X.alias.join(","):X.alias;Y.push(`alias:${Z}`)}if(X.cwd)Y.push(`cwd:${X.cwd}`);if(X.configDir)Y.push(`configDir:${X.configDir}`);if("checkEnv"in X)Y.push(`checkEnv:${X.checkEnv}`);return Y.join("|")}getLocalDirectories(Q,X){return Array.from(new Set([Q,d(Q,"config"),d(Q,".config"),X?d(Q,X):void 0].filter(Boolean)))}getAllSearchPaths(Q,X,Y,Z){let $=[];return $.push(...this.getLocalSearchPaths(Q,X,Y,Z)),$.push(...this.getHomeSearchPaths(Q,X)),$.push(d(Y,"package.json")),$}getLocalSearchPaths(Q,X,Y,Z){let $=this.getLocalDirectories(Y,Z),H=[];for(let U of $)H.push(...this.fileLoader.generateConfigPaths(Q,U,X));return H}getHomeSearchPaths(Q,X){if(!Q)return[];let Y=[d(YQ(),".config",Q),d(YQ(),".config"),YQ()],Z=[];for(let $ of Y)Z.push(...this.fileLoader.generateConfigPaths(Q,$,X));return Z}async loadConfigWithResult(Q){return this.loadConfig(Q)}}var MX=new BZ;async function RZ(Q){let X="defaultConfig"in Q&&Q.defaultConfig!==void 0?Q.defaultConfig:{},Y="cache"in Q||"performance"in Q||"schema"in Q||"validate"in Q;try{let Z;if(Y)Z=await MX.loadConfig(Q);else Z=await MX.loadConfig({...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}});return Z?.config??X}catch(Z){let $=Z instanceof Error?Z.name:"UnknownError",H=Z instanceof Error?Z.message:String(Z);if(!($==="ConfigNotFoundError"||$==="ConfigLoadError"||$==="ConfigValidationError"||H.includes("config"))&&Q.verbose)c.warn("Unexpected error loading config, using defaults:",[Z instanceof Error?Z:Error(String(Z))]);let G=Y?{...Q,defaultConfig:X}:{...Q,defaultConfig:X,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in Q?Q.checkEnv!==!1:!0)return(await MX.applyEnvironmentVariables(G.name||"",X,!0,G.verbose||!1))?.config??X;return X}}function PQ(Q,X,Y=!1){let Z=new cX,$=Q.toUpperCase().replace(/[^A-Z0-9]/g,"_");function H(U,G=[]){let J={...U};for(let[_,q]of Object.entries(U)){let W=[...G,_],z=[`${$}_${W.join("_").toUpperCase()}`,`${$}_${W.map((B)=>B.toUpperCase()).join("")}`,`${$}_${W.map((B)=>B.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],A,I;for(let B of z)if(A=eQ.env[B],A!==void 0){I=B;break}if(A!==void 0&&I)if(typeof q==="boolean")J[_]=["true","1","yes"].includes(A.toLowerCase());else if(typeof q==="number"){let B=Number(A);if(!Number.isNaN(B))J[_]=B}else if(Array.isArray(q))try{J[_]=JSON.parse(A)}catch{J[_]=A.split(",").map((B)=>B.trim())}else J[_]=A;else if(q&&typeof q==="object"&&!Array.isArray(q))J[_]=H(q,W)}return J}return H(X)}var J$=d(eQ.cwd(),"config"),G$=d(eQ.cwd(),"src/generated");var S8=["code-style","lint"],wZ={ignores:["**/node_modules/**","**/.pnpm/**","**/.yarn/**","**/dist/**","**/build/**","**/out/**","**/.output/**","**/.next/**","**/.nuxt/**","**/.vite/**","**/.turbo/**","**/.cache/**","**/coverage/**","**/vendor/**","**/pantry/**","**/tmp/**","**/.git/**","**/.idea/**","**/.vscode/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/*.test.ts","**/*.spec.ts","**/.bunpress/**","**/.vitepress/cache/**","**/storage/framework/stx/**","**/storage/framework/runtime/**","**/*.lock","**/package-lock.json","**/pnpm-lock.yaml"],lint:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],reporter:"stylish",cache:!1,maxWarnings:-1},format:{extensions:["ts","js","html","css","json","jsonc","md","yaml","yml","stx","sh","bash","zsh"],trimTrailingWhitespace:!0,maxConsecutiveBlankLines:1,finalNewline:"one",indent:2,indentStyle:"spaces",preserveCodeIndentation:!1,quotes:"single",semi:!1},rules:{noDebugger:"error",noConsole:"warn"},pluginRules:{"style/brace-style":"warn","style/curly":"off","style/if-newline":"off","style/max-statements-per-line":"warn","pickier/import-dedupe":"warn","pickier/no-import-node-modules-by-path":"error","pickier/no-import-dist":"error","pickier/prefer-const":"error","pickier/prefer-template":"warn","pickier/no-unused-vars":"error","pickier/sort-tailwind-classes":"warn","regexp/no-unused-capturing-group":"error","regexp/no-super-linear-backtracking":"error","regexp/no-useless-lazy":"error","ts/no-top-level-await":"error","ts/member-delimiter-style":"off","ts/type-annotation-spacing":"off","style/comma-dangle":"off","style/keyword-spacing":"off","style/arrow-spacing":"off","style/space-infix-ops":"off","style/object-curly-spacing":"off","style/spaced-comment":"off","style/block-spacing":"off","style/space-before-blocks":"off","style/comma-spacing":"off","style/semi-spacing":"off","style/rest-spread-spacing":"off","style/key-spacing":"off","style/computed-property-spacing":"off","style/array-bracket-spacing":"off","style/space-in-parens":"off","style/template-curly-spacing":"off","style/space-unary-ops":"off","style/switch-colon-spacing":"off","style/arrow-parens":"off","style/space-before-function-paren":"off","style/quote-props":"off","style/no-floating-decimal":"off","style/new-parens":"off","style/no-extra-parens":"off","style/wrap-iife":"off","style/comma-style":"off","style/dot-location":"off","style/operator-linebreak":"off","style/multiline-ternary":"off","style/padded-blocks":"off","style/lines-between-class-members":"off","style/no-tabs":"off","style/no-mixed-spaces-and-tabs":"off","style/generator-star-spacing":"off","style/yield-star-spacing":"off","style/function-call-spacing":"off","style/template-tag-spacing":"off","style/no-whitespace-before-property":"off","style/no-mixed-operators":"off","style/indent-binary-ops":"off","ts/type-generic-spacing":"off","ts/type-named-tuple-spacing":"off","markdown/heading-increment":"warn","markdown/heading-style":"warn","markdown/no-missing-space-atx":"error","markdown/no-multiple-space-atx":"error","markdown/no-missing-space-closed-atx":"error","markdown/no-multiple-space-closed-atx":"error","markdown/blanks-around-headings":"warn","markdown/heading-start-left":"warn","markdown/no-duplicate-heading":"warn","markdown/single-title":"warn","markdown/no-trailing-punctuation":"warn","markdown/ul-style":"warn","markdown/list-indent":"error","markdown/ul-indent":"warn","markdown/ol-prefix":"warn","markdown/list-marker-space":"error","markdown/blanks-around-lists":"warn","markdown/no-trailing-spaces":"error","markdown/no-hard-tabs":"error","markdown/no-multiple-blanks":"warn","markdown/no-multiple-space-blockquote":"error","markdown/no-blanks-blockquote":"warn","markdown/blanks-around-fences":"warn","markdown/single-trailing-newline":"error","markdown/blanks-around-tables":"warn","markdown/no-reversed-links":"error","markdown/no-bare-urls":"warn","markdown/no-space-in-links":"error","markdown/no-empty-links":"error","markdown/link-fragments":"warn","markdown/reference-links-images":"warn","markdown/link-image-reference-definitions":"warn","markdown/link-image-style":"warn","markdown/descriptive-link-text":"warn","markdown/line-length":"off","markdown/commands-show-output":"warn","markdown/fenced-code-language":"warn","markdown/code-block-style":"off","markdown/code-fence-style":"warn","markdown/no-emphasis-as-heading":"warn","markdown/no-space-in-emphasis":"warn","markdown/no-space-in-code":"warn","markdown/emphasis-style":"warn","markdown/strong-style":"warn","markdown/no-inline-html":"off","markdown/hr-style":"warn","markdown/first-line-heading":"off","markdown/required-headings":"off","markdown/proper-names":"off","markdown/no-alt-text":"warn","markdown/table-pipe-style":"warn","markdown/table-column-count":"warn","markdown/table-column-style":"warn","lockfile/validate-host":["warn",{allowedHosts:["npm","yarn"]}],"lockfile/validate-https":"error","lockfile/validate-integrity":["warn",{requiredAlgorithm:"sha512"}],"lockfile/validate-package-names":"error","lockfile/validate-scheme":["error",{allowedSchemes:["https:","git+https:","git+ssh:"]}],"publint/exports-types-should-be-first":"error","publint/exports-default-should-be-last":"error","publint/exports-module-should-precede-require":"error","publint/exports-value-invalid":"error","publint/imports-key-invalid":"error","publint/imports-value-invalid":"error","publint/imports-default-should-be-last":"error","publint/imports-module-should-precede-require":"error","publint/use-type":"warn","publint/deprecated-field-jsnext":"warn","publint/field-invalid-value-type":"error","publint/local-dependency":"error","publint/has-module-but-no-exports":"warn","publint/exports-missing-root-entrypoint":"warn","publint/exports-fallback-array-use":"warn","publint/file-does-not-exist":"warn","publint/file-invalid-format":"warn","publint/module-should-be-esm":"error","publint/bin-file-not-executable":"error","publint/exports-module-should-be-esm":"error","shell/command-substitution":"error","shell/quote-variables":"warn","shell/no-cd-without-check":"warn","shell/no-eval":"error","shell/no-useless-cat":"warn","shell/shebang":"warn","shell/indent":"warn","shell/function-style":"warn","shell/operator-spacing":"warn","shell/keyword-spacing":"warn","shell/no-trailing-semicolons":"warn","shell/no-trailing-whitespace":"error","shell/prefer-double-brackets":"warn","shell/set-options":"off","shell/prefer-printf":"warn","shell/consistent-case-terminators":"warn","shell/no-broken-redirect":"error","shell/heredoc-indent":"warn","shell/no-ls-parsing":"warn","shell/no-variable-in-single-quotes":"warn","shell/no-exit-in-subshell":"warn","spell/check":"off","spell/check-comments":"off","spell/check-markdown":"off"},verbose:!0},lX=null;async function W$(){if(!lX)lX=await RZ({name:"pickier",alias:[...S8],defaultConfig:wZ});return lX}var A$=wZ;
|
|
62
62
|
export{wZ as I,W$ as J,A$ as K};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{I as P}from"./chunk-
|
|
3
|
-
`),Z=V.length,X=Array(Z),J=Y.format.indent,H=Y.format.indentStyle==="tabs",U=0,Q=!1,F="",z=!1,G=0;for(let W=0;W<Z;W++){let D=V[W];if(D.length===0||/^\s*$/.test(D)){X[W]="";continue}if(Q){if(X[W]=D,D.trim()===F)Q=!1,F="";continue}let M=o(D);if(M)Q=!0,F=M;let A=0;while(A<D.length&&(D.charCodeAt(A)===32||D.charCodeAt(A)===9))A++;let B=D.slice(A).trimEnd();if(B.startsWith("#")&&W>0){let
|
|
2
|
+
import{I as P}from"./chunk-sa6phv2n.js";import{L as F0}from"./chunk-h6ac3d60.js";function qZ($){let Y=$.length,V=Array.from({length:Y},(X,J)=>$[J]),Z=0;while(Z<Y){let X=$[Z];if(X==="#"&&(Z===0||/\s/.test($[Z-1]))){while(Z<Y)V[Z]=" ",Z++;break}if(X==="$"&&$[Z+1]==="'"){Z+=2;while(Z<Y){if($[Z]==="\\"&&Z+1<Y){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if($[Z]==="'"){Z++;break}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==='"'){Z++,Z=x($,Z,V);continue}if(X==="$"&&$[Z+1]==="{"){Z+=2;let J=1;while(Z<Y&&J>0){let H=$[Z];if(H==="\\"&&Z+1<Y){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if(H==="'"){Z++;while(Z<Y&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<Y)Z++;continue}if(H==='"'){Z=x($,Z,V);continue}if(H==="{"){J++,Z++;continue}if(H==="}"){J--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==="("&&$[Z+2]==="("){Z+=3;let J=2;while(Z<Y&&J>0){let H=$[Z];if(H==="("){J++,Z++;continue}if(H===")"){J--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="$"&&$[Z+1]==="("){Z+=2;let J=1;while(Z<Y&&J>0){let H=$[Z];if(H==="\\"&&Z+1<Y){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}if(H==="'"){Z++;while(Z<Y&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<Y)Z++;continue}if(H==='"'){Z=x($,Z,V);continue}if(H==="("){J++,Z++;continue}if(H===")"){J--,Z++;continue}V[Z]=" ",Z++}continue}if(X==="'"){Z++;while(Z<Y&&$[Z]!=="'")V[Z]=" ",Z++;if(Z<Y)Z++;continue}if(X==='"'){Z=x($,Z,V);continue}if(X==="`"){Z++;while(Z<Y&&$[Z]!=="`"){if($[Z]==="\\"&&Z+1<Y){V[Z]=" ",V[Z+1]=" ",Z+=2;continue}V[Z]=" ",Z++}if(Z<Y)Z++;continue}Z++}return V.join("")}function x($,Y,V){let Z=$.length,X=Y+1;while(X<Z){let J=$[X];if(J==="\\"&&X+1<Z){V[X]=" ",V[X+1]=" ",X+=2;continue}if(J==='"')return X+1;if(J==="$"&&$[X+1]==="("&&$[X+2]==="("){X+=3;let H=2;while(X<Z&&H>0){let U=$[X];if(U==="("){H++,X++;continue}if(U===")"){H--,X++;continue}V[X]=" ",X++}continue}if(J==="$"&&$[X+1]==="("){X+=2;let H=1;while(X<Z&&H>0){let U=$[X];if(U==="\\"&&X+1<Z){V[X]=" ",V[X+1]=" ",X+=2;continue}if(U==="'"){X++;while(X<Z&&$[X]!=="'")V[X]=" ",X++;if(X<Z)X++;continue}if(U==='"'){X=x($,X,V);continue}if(U==="("){H++,X++;continue}if(U===")"){H--,X++;continue}V[X]=" ",X++}continue}if(J==="$"&&$[X+1]==="{"){X+=2;let H=1;while(X<Z&&H>0){let U=$[X];if(U==="{"){H++,X++;continue}if(U==="}"){H--,X++;continue}V[X]=" ",X++}continue}V[X]=" ",X++}return X}function o($){let V=qZ($).match(/<<-?/);if(!V||V.index===void 0)return null;let X=$.slice(V.index+V[0].length).match(/^\s*(['"]?)(\w+)\1/);if(!X)return null;return X[2]}var QZ=new Set([".ts",".js"]),KZ=new Set([".json",".jsonc"]),FZ=new Set([".yaml",".yml"]),zZ=new Set([".sh",".bash",".zsh",".ksh",".dash"]),BZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;var GZ=/^[}\])]/,DZ=/[{[(]\s*$/,yZ=/\s*\/\/.*$/,MZ=/^(?:if|else\s+if|for|while)\s*\(/,AZ=/^(?:\.[\w$[]|\?[\s.:]|:\s|&&|\|\|)/;function OZ($){let Y=MZ.exec($);if(!Y)return/^(?:else|do)\s*$/.test($);let V=0,Z=null;for(let X=Y[0].length-1;X<$.length;X++){let J=$[X];if(Z){if(J==="\\"){X++;continue}if(J===Z)Z=null;continue}if(J==="'"||J==='"'||J==="`"){Z=J;continue}if(J==="(")V++;else if(J===")"){if(V--,V===0)return $.slice(X+1).trim().length===0}}return!1}var NZ=/^\s*for\s*\(/,jZ=new RegExp("^\\s*;\\s*$"),IZ=new RegExp(";{2,}\\s*$"),RZ=/([\w)])\{/g,wZ=/\{(return|if|for|while|switch|const|let|var|function)\b/g,LZ=/,(\S)/g,vZ=/(?<![=!<>+\-*/%&|^?])=(?![=><])/g,PZ=/(\w)\+(\w)/g,_Z=/(\w)-(\w)/g,TZ=/(\w)\*(\w)/g,CZ=/(\w)\/(\w)/g,EZ=new RegExp("(?<=\\S);([^\\s;])","g"),xZ=/([\w)\]])<(\d)/g,kZ=/([\w)\]])>(\d)/g,a=/\s{2,}/g,l=/^\s*$/,SZ=/^\s*\/\//,r=/^\s*\/\*/,bZ=/^\s*import\b/,s=/\bfrom\s*['"][^'"]+['"]|^\s*import\s+['"][^'"]+['"]/,fZ=/package\.json$/i,hZ=/[jt]sconfig(?:\..+)?\.json$/i,f=/[ \t]+$/,gZ=/^\n+/;function S($){let Y=$.lastIndexOf(".");return Y>=0?$.slice(Y):""}function h($){return QZ.has(S($))}function mZ($){return KZ.has(S($))}function uZ($){return FZ.has(S($))}function cZ($){return zZ.has(S($))}function pZ($,Y){return cZ($)||BZ.test(Y)}function dZ($,Y){let V=$.split(`
|
|
3
|
+
`),Z=V.length,X=Array(Z),J=Y.format.indent,H=Y.format.indentStyle==="tabs",U=0,Q=!1,F="",z=!1,G=0;for(let W=0;W<Z;W++){let D=V[W];if(D.length===0||/^\s*$/.test(D)){X[W]="";continue}if(Q){if(X[W]=D,D.trim()===F)Q=!1,F="";continue}let M=o(D);if(M)Q=!0,F=M;let A=0;while(A<D.length&&(D.charCodeAt(A)===32||D.charCodeAt(A)===9))A++;let B=D.slice(A).trimEnd();if(B.startsWith("#")&&W>0){let E=H?"\t".repeat(U):" ".repeat(U*J);X[W]=E+B;continue}if(/^case\b/.test(B)&&/\bin\s*$/.test(B))G++,z=!0;if(/^esac\b/.test(B)){if(G=Math.max(0,G-1),G===0)z=!1}let j=z&&/\)\s*$/.test(B)&&!/\$\(/.test(B)&&!/^\s*\(/.test(B)&&!B.startsWith("#"),I=/^;[;&]\s*$/.test(B);if(/^(?:fi|done|esac|elif|else)\b/.test(B)||/^\}/.test(B))U=Math.max(0,U-1);if(I)U=Math.max(0,U-1);let C=H?"\t".repeat(U):" ".repeat(U*J);if(X[W]=C+B,/^then\b/.test(B)||/^do\b/.test(B)||/^else\b/.test(B))U++;else if(/^if\b/.test(B)&&/\bthen\s*$/.test(B))U++;else if(/^elif\b/.test(B)&&/\bthen\s*$/.test(B))U++;else if(/^(?:while|for|until)\b/.test(B)&&/\bdo\s*$/.test(B))U++;else if(/^case\b/.test(B)&&/\bin\s*$/.test(B))U++;else if(j)U++;else if(/\{\s*$/.test(B)&&!B.startsWith("#"))U++}return X.join(`
|
|
4
4
|
`)}function oZ($,Y){try{let V=Bun.YAML.parse($),Z=Y.format.indentStyle==="tabs"?"\t":Y.format.indent;return Bun.YAML.stringify(V,null,Z).split(`
|
|
5
5
|
`).map((J)=>J.replace(/[ \t]+$/,"")).join(`
|
|
6
|
-
`)}catch{return $}}function aZ($){return" ".repeat(Math.max(0,$))}function lZ($,Y){if((Y.format.indentStyle||"spaces")==="tabs")return"\t".repeat(Math.max(0,$));return aZ(Math.max(0,$*Y.format.indent))}function rZ($){return`'${$.slice(1,-1).replace(/\\"/g,'"')}'`}function sZ($){return`"${$.slice(1,-1).replace(/\\'/g,"'")}"`}function nZ($,Y){for(let V=0;V<$.length;V++){if($[V]==="\\"){V++;continue}if($[V]===Y)return!0}return!1}function tZ($,Y,V){if(!
|
|
6
|
+
`)}catch{return $}}function aZ($){return" ".repeat(Math.max(0,$))}function lZ($,Y){if((Y.format.indentStyle||"spaces")==="tabs")return"\t".repeat(Math.max(0,$));return aZ(Math.max(0,$*Y.format.indent))}function rZ($){return`'${$.slice(1,-1).replace(/\\"/g,'"')}'`}function sZ($){return`"${$.slice(1,-1).replace(/\\'/g,"'")}"`}function nZ($,Y){for(let V=0;V<$.length;V++){if($[V]==="\\"){V++;continue}if($[V]===Y)return!0}return!1}function tZ($,Y,V){if(!h(V))return $;let Z=$.split(`
|
|
7
7
|
`);for(let X=0;X<Z.length;X++)Z[X]=e(Z[X],Y);return Z.join(`
|
|
8
|
-
`)}function e($,Y){let V=Y==="single";if(V?!$.includes('"'):!$.includes("'"))return $;let Z=[],X=0,J=0,H=0,U=0;while(X<$.length){let Q=$[X];if(H===0){if(Q==="/"){let F=$[X+1];if(F==="/")break;if(F==="*"){let z=$.indexOf("*/",X+2);X=z===-1?$.length:z+2;continue}if(VZ($,X)){let z=XZ($,X);if(z!==-1){X=z;continue}}X++;continue}if(Q==='"'){H=2,U=X,X++;continue}if(Q==="'"){H=1,U=X,X++;continue}if(Q==="`"){H=3,X++;continue}X++}else if(H===3){if(Q==="\\"){X+=2;continue}if(Q==="`")H=0;X++}else{if(Q==="\\"){X+=2;continue}if(Q===(H===1?"'":'"')){let z=$.slice(U+1,X);if((H===2&&V||H===1&&!V)&&!nZ(z,V?"'":'"')){if(U>J)Z.push($.slice(J,U));if(H===2)Z.push(rZ(`"${z}"`));else Z.push(sZ(`'${z}'`));J=X+1}H=0,X++;continue}X++}}if(Z.length===0)return $;if(J<$.length)Z.push($.slice(J));return Z.join("")}var iZ=new Set(["{",",","=","+","-","*","/",";","<",">"]);function eZ($){if($.length<4)return $;let Y=0;while(Y<$.length&&($[Y]===" "||$[Y]==="\t"))Y++;if(Y<$.length){let H=$[Y];if(H==="/"&&($[Y+1]==="/"||$[Y+1]==="*"))return $;if(H==="*")return $}let V=!1;for(let H=Y;H<$.length;H++)if(iZ.has($[H])){V=!0;break}if(!V)return $;let{text:Z,strings:X}=X0($),J=Z;if(J=J.replace(
|
|
9
|
-
`),Z=V.length,X=Array(Z),J=Y.format.quotes,H=Y.format.semi===!0,U=0,Q=0,F=!1,z=[];for(let G=0;G<Z;G++){let W=V[G];if(F){F=n(W,!0),X[G]=W;continue}let D=
|
|
10
|
-
`)}function $0($,Y){let V=[],Z=0,X=[];for(let J of $){let H=
|
|
8
|
+
`)}function e($,Y){let V=Y==="single";if(V?!$.includes('"'):!$.includes("'"))return $;let Z=[],X=0,J=0,H=0,U=0;while(X<$.length){let Q=$[X];if(H===0){if(Q==="/"){let F=$[X+1];if(F==="/")break;if(F==="*"){let z=$.indexOf("*/",X+2);X=z===-1?$.length:z+2;continue}if(VZ($,X)){let z=XZ($,X);if(z!==-1){X=z;continue}}X++;continue}if(Q==='"'){H=2,U=X,X++;continue}if(Q==="'"){H=1,U=X,X++;continue}if(Q==="`"){H=3,X++;continue}X++}else if(H===3){if(Q==="\\"){X+=2;continue}if(Q==="`")H=0;X++}else{if(Q==="\\"){X+=2;continue}if(Q===(H===1?"'":'"')){let z=$.slice(U+1,X);if((H===2&&V||H===1&&!V)&&!nZ(z,V?"'":'"')){if(U>J)Z.push($.slice(J,U));if(H===2)Z.push(rZ(`"${z}"`));else Z.push(sZ(`'${z}'`));J=X+1}H=0,X++;continue}X++}}if(Z.length===0)return $;if(J<$.length)Z.push($.slice(J));return Z.join("")}var iZ=new Set(["{",",","=","+","-","*","/",";","<",">"]);function eZ($){if($.length<4)return $;let Y=0;while(Y<$.length&&($[Y]===" "||$[Y]==="\t"))Y++;if(Y<$.length){let H=$[Y];if(H==="/"&&($[Y+1]==="/"||$[Y+1]==="*"))return $;if(H==="*")return $}let V=!1;for(let H=Y;H<$.length;H++)if(iZ.has($[H])){V=!0;break}if(!V)return $;let{text:Z,strings:X}=X0($),J=Z;if(J=J.replace(RZ,"$1 {"),J=J.replace(wZ,"{ $1"),J=J.replace(LZ,", $1"),J=J.replace(vZ," = "),J=J.replace(PZ,"$1 + $2"),J=J.replace(_Z,"$1 - $2"),J=J.replace(TZ,"$1 * $2"),J=J.replace(CZ,"$1 / $2"),J=J.replace(EZ,"; $1"),J=J.replace(xZ,"$1 < $2"),J=J.replace(kZ,"$1 > $2"),Y>0){let H=J.slice(Y);J=J.slice(0,Y)+H.replace(a," ")}else J=J.replace(a," ");return X.length>0?Y0(J,X):J}function b($){let Y=$[$.length-1];return Y!==void 0&&Y.t==="tmpl"}function ZZ($,Y,V){Y++;while(Y<$.length){let Z=$[Y];if(Z==="\\"){Y+=2;continue}if(Z===V)return Y+1;Y++}return Y}function g($,Y){for(let Z of Y)if(Z.t==="tmpl")Z.start=-1;let V=0;while(V<$.length){let Z=Y[Y.length-1],X=$[V];if(Z===void 0||Z.t==="interp"){if(X==="`"){Y.push({t:"tmpl",start:V}),V++;continue}if(X==="'"||X==='"'){V=ZZ($,V,X);continue}if(X==="/"&&$[V+1]==="/")break;if(Z!==void 0){if(X==="{"){Z.braces++,V++;continue}if(X==="}"){if(Z.braces===0)Y.pop();else Z.braces--;V++;continue}}V++}else{if(X==="\\"){V+=2;continue}if(X==="`"){Y.pop(),V++;continue}if(X==="$"&&$[V+1]==="{"){Y.push({t:"interp",braces:0}),V+=2;continue}V++}}if(b(Y)){for(let Z of Y)if(Z.t==="tmpl"&&Z.start>=0)return Z.start}return-1}function n($,Y){let V=Y,Z=null,X=0;while(X<$.length){let J=$[X];if(V){if(J==="*"&&$[X+1]==="/"){V=!1,X+=2;continue}X++;continue}if(Z){if(J==="\\"){X+=2;continue}if(J===Z)Z=null;X++;continue}if(J==="'"||J==='"'||J==="`"){Z=J,X++;continue}if(J==="/"){if($[X+1]==="/")break;if($[X+1]==="*"){V=!0,X+=2;continue}}X++}return V}function Z0($,Y){let V=$.split(`
|
|
9
|
+
`),Z=V.length,X=Array(Z),J=Y.format.quotes,H=Y.format.semi===!0,U=0,Q=0,F=!1,z=[];for(let G=0;G<Z;G++){let W=V[G];if(F){F=n(W,!0),X[G]=W;continue}let D=b(z),M=-1;if(z.length>0||W.indexOf("`")!==-1)M=g(W,z);if(D){X[G]=W;continue}if(M<0&&z.length===0)F=n(W,!1);let A="",B=!1,j="";if(M>=0){A=W.slice(M);let L=W.slice(0,M);if(L.length===0){X[G]=A;continue}if(B=f.test(L),L.trim().length===0)j=L;W=L}if(W.length===0){X[G]="";continue}W=e(W,J);let I=0;while(I<W.length&&(W.charCodeAt(I)===32||W.charCodeAt(I)===9))I++;let R=W.slice(I).trimEnd();if(GZ.test(R))U=Math.max(0,U-1);let C=AZ.test(R)?1:0,E=W.slice(0,I);if(W=Y.format.preserveCodeIndentation?E+R:lZ(U+Q+C,Y)+R,DZ.test(R))U+=1,Q=0;else if(!R.startsWith("//")&&!R.startsWith("*")&&!R.startsWith("/*")){let L=R.replace(yZ,"");Q=OZ(L)?Q+1:0}if(W=eZ(W),H){if(!NZ.test(W))if(jZ.test(W))W="";else W=W.replace(IZ,";")}if(Y.format.trimTrailingWhitespace)W=W.trimEnd();if(M>=0){if(j)W=j;else if(B&&!f.test(W))W+=" ";W+=A}X[G]=W}return X.join(`
|
|
10
|
+
`)}function $0($,Y){let V=[],Z=0,X=[];for(let J of $){let H=b(X);if(X.length>0||J.indexOf("`")!==-1)g(J,X);if(H){V.push(J),Z=0;continue}if(J===""){if(Z++,Z<=Y)V.push("")}else Z=0,V.push(J)}return V}function _0($,Y,V){if($.length===0)return"";let X=($.includes("\r")?$.replace(/\r\n/g,`
|
|
11
11
|
`):$).split(`
|
|
12
|
-
`),J;if(Y.format.trimTrailingWhitespace){J=[];let F=0,z=Math.max(0,Y.format.maxConsecutiveBlankLines),G=[];for(let W of X){let D=
|
|
13
|
-
`);if(H=H.replace(gZ,""),
|
|
12
|
+
`),J;if(Y.format.trimTrailingWhitespace){J=[];let F=0,z=Math.max(0,Y.format.maxConsecutiveBlankLines),G=[];for(let W of X){let D=b(G),M=!1;if(G.length>0||W.indexOf("`")!==-1)M=g(W,G)>=0;if(D||M){J.push(W),F=0;continue}let A=W[W.length-1],B=A===" "||A==="\t"?W.replace(f,""):W;if(B===""){if(F++,F<=z)J.push("")}else F=0,J.push(B)}}else J=$0(X,Math.max(0,Y.format.maxConsecutiveBlankLines));let H=J.join(`
|
|
13
|
+
`);if(H=H.replace(gZ,""),h(V))H=H0(H);if(uZ(V)){let F=oZ(H,Y);if(F!==H)H=F}if(mZ(V)){let F=q0(H,V);if(F!=null)H=F}if(pZ(V,H))H=dZ(H,Y);else if(h(V))H=Z0(H,Y);else H=tZ(H,Y.format.quotes,V);if(Y.format.finalNewline==="none")return H.replace(/\n+$/g,"");let U=/[^\n]\n$/.test(H)||H===`
|
|
14
14
|
`,Q=/\n\n$/.test(H);if(Y.format.finalNewline==="two"){if(Q)return H;if(U)return`${H}
|
|
15
15
|
`;return`${H}
|
|
16
16
|
|
|
@@ -18,16 +18,16 @@ import{I as P}from"./chunk-5wzkpgv6.js";import{L as F0}from"./chunk-h6ac3d60.js"
|
|
|
18
18
|
`);if(U)return H;return`${H}
|
|
19
19
|
`}function t($,Y,V,Z){for(let X=Y+1;X<$.length;X++){let J=$[X];if(J==="\\"){X++;continue}if(J===V)return!0;if(J===Z)return!1}return!0}function T0($,Y){if(/^\s*\/\/\/\s*<reference/.test($))return[];let V=[],Z=null,X=!1;for(let J=0;J<$.length;J++){let H=$[J];if(X){X=!1;continue}if(H==="\\"){X=!0;continue}if(!Z){if(H==="/"&&$[J+1]==="/")break;if(H==="'"){if(Y==="double"&&t($,J,"'",'"'))V.push(J);Z="single";continue}else if(H==='"'){if(Y==="single"&&t($,J,'"',"'"))V.push(J);Z="double";continue}else if(H==="`"){Z="template";continue}}else if(Z==="single"&&H==="'"||Z==="double"&&H==='"'||Z==="template"&&H==="`"){Z=null;continue}}return V}function C0($,Y,V="spaces",Z){if(V==="tabs")return/[^\t]/.test($);if(/\t/.test($))return!0;let X=$.length;if(Z&&X%Y===1){let J=Z.trimStart();if(J.startsWith("* ")||J.startsWith("*/")||J==="*")return!1}return X%Y!==0}function $Z($,Y){let V=Y+1;while(V<$.length){let Z=$[V];if(Z==="\\"){V+=2;continue}if(Z==="`")return V+1;if(Z==="$"&&$[V+1]==="{"){V+=2;let X=1;while(V<$.length&&X>0){let J=$[V];if(J==="\\"){V+=2;continue}if(J==="`"){V=$Z($,V);continue}if(J==="'"||J==='"'){V=ZZ($,V,J);continue}if(J==="{")X++;else if(J==="}")X--;V++}continue}V++}return V}var V0=new Set(["return","typeof","instanceof","in","of","new","delete","void","do","else","case","yield","await"]);function VZ($,Y){let V=Y-1;while(V>=0&&($[V]===" "||$[V]==="\t"))V--;if(V<0)return!0;let Z=$[V];if("(,=:[!&|?;{}<>+-*%^~".includes(Z))return!0;if(/[\w$]/.test(Z)){let X=V;while(X>=0&&/[\w$]/.test($[X]))X--;return V0.has($.slice(X+1,V+1))}return!1}function XZ($,Y){let V=Y+1,Z=!1,X=-1;while(V<$.length){let J=$[V];if(J==="\\"){V+=2;continue}if(J==="["&&!Z)Z=!0,X=V;else if(J==="]"&&Z){let H=$[X+1]==="^"?X+2:X+1;if(V!==H)Z=!1}else if(J==="/"&&!Z){V++;while(V<$.length&&/[a-z]/i.test($[V]))V++;return V}V++}return-1}function X0($){if(!$.includes("'")&&!$.includes('"')&&!$.includes("`")&&!$.includes("/"))return{text:$,strings:[]};let Y=[],V=[],Z=0,X=0;while(Z<$.length){let J=$[Z];if(J==="/"){let H=$[Z+1];if(H==="/"){if(Z>X)V.push($.slice(X,Z));Y.push($.slice(Z)),V.push(`@@S${Y.length-1}@@`),X=$.length;break}if(H==="*"){let U=$.indexOf("*/",Z+2),Q=U===-1?$.length:U+2;if(Z>X)V.push($.slice(X,Z));Y.push($.slice(Z,Q)),V.push(`@@S${Y.length-1}@@`),Z=Q,X=Z;continue}if(VZ($,Z)){let U=XZ($,Z);if(U!==-1){if(Z>X)V.push($.slice(X,Z));Y.push($.slice(Z,U)),V.push(`@@S${Y.length-1}@@`),Z=U,X=Z;continue}}Z++;continue}if(J==="'"||J==='"'||J==="`"){if(Z>X)V.push($.slice(X,Z));let H=Z;if(J==="`")Z=$Z($,Z);else{let U=J;Z++;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]===U){Z++;break}Z++}}Y.push($.slice(H,Z)),V.push(`@@S${Y.length-1}@@`),X=Z;continue}Z++}if(X<$.length)V.push($.slice(X));return{text:V.join(""),strings:Y}}function Y0($,Y){if(Y.length===0)return $;return $.replace(/@@S(\d+)@@/g,(V,Z)=>Y[Number(Z)]??"")}function J0($){let Y=new Set,V=/[$A-Z_][\w$]*/gi,Z=V.exec($);while(Z!==null)Y.add(Z[0]),Z=V.exec($);return Y}function H0($){let Y=$[0];if(Y!=="i"&&Y!==" "&&Y!=="\t"&&Y!=="/"&&Y!==`
|
|
20
20
|
`)return $;let V=$.split(`
|
|
21
|
-
`),Z=[],X=[],J=[],H=0,U=0,Q=-1,F=!1;while(H<V.length){let q=V[H];if(l.test(q)){H++;continue}if(SZ.test(q)||r.test(q)){let y=H;if(r.test(q)){while(H<V.length&&!V[H].includes("*/"))H++;H++}else H++;if(!F){for(let
|
|
22
|
-
`),W=J0(G),D=(q)=>W.has(q);for(let q of Z){if(q.kind!=="value")continue;q.named=q.named.filter((K)=>{if(K.alias)return!0;return D(K.name)})}let M=Z.filter((q)=>{if(q.kind==="side-effect")return!0;if(q.kind==="type")return q.namedTypes.length>0;return Boolean(q.defaultName||q.namespaceName||q.named.length>0)}),A=new Map;for(let q of M){let K=A.get(q.source)||{};if(q.kind==="side-effect")K.side=K.side||[],K.side.push(q);else if(q.kind==="type"){if(!K.type)K.type={kind:"type",source:q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=(K.type.namedTypes||[]).concat(q.namedTypes)}else{if(!K.value)K.value={kind:"value",source:q.source,named:[],namedTypes:[],original:""};if(q.defaultName)K.value.defaultName=q.defaultName;if(q.namespaceName)K.value.namespaceName=q.namespaceName;if(K.value.named=(K.value.named||[]).concat(q.named),q.namedTypes.length>0){if(!K.type)K.type={kind:"type",source:q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=K.type.namedTypes.concat(q.namedTypes)}}A.set(q.source,K)}let B=[];for(let[q,K]of A){if(K.side)B.push(...K.side);if(K.value){let
|
|
21
|
+
`),Z=[],X=[],J=[],H=0,U=0,Q=-1,F=!1;while(H<V.length){let q=V[H];if(l.test(q)){H++;continue}if(SZ.test(q)||r.test(q)){let y=H;if(r.test(q)){while(H<V.length&&!V[H].includes("*/"))H++;H++}else H++;if(!F){for(let w=y;w<H&&w<V.length;w++)X.push(V[w]);U=H}else if(Q<0)Q=y;continue}if(!bZ.test(q))break;let K=q.trim(),N=H+1;while(!s.test(K)&&N<V.length&&N-H<50)K+=` ${V[N].trim()}`,N++;if(!s.test(K))return $;let O=W0(K);if(!O)return $;if(Q>=0){for(let y=Q;y<H;y++)if(!l.test(V[y]))J.push(V[y]);Q=-1}Z.push(O),H=N,U=H,F=!0}if(Z.length===0)return $;let z=Q>=0?Q:U,G=V.slice(z).join(`
|
|
22
|
+
`),W=J0(G),D=(q)=>W.has(q);for(let q of Z){if(q.kind!=="value")continue;q.named=q.named.filter((K)=>{if(K.alias)return!0;return D(K.name)})}let M=Z.filter((q)=>{if(q.kind==="side-effect")return!0;if(q.kind==="type")return q.namedTypes.length>0;return Boolean(q.defaultName||q.namespaceName||q.named.length>0)}),A=new Map;for(let q of M){let K=A.get(q.source)||{};if(q.kind==="side-effect")K.side=K.side||[],K.side.push(q);else if(q.kind==="type"){if(!K.type)K.type={kind:"type",source:q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=(K.type.namedTypes||[]).concat(q.namedTypes)}else{if(!K.value)K.value={kind:"value",source:q.source,named:[],namedTypes:[],original:""};if(q.defaultName)K.value.defaultName=q.defaultName;if(q.namespaceName)K.value.namespaceName=q.namespaceName;if(K.value.named=(K.value.named||[]).concat(q.named),q.namedTypes.length>0){if(!K.type)K.type={kind:"type",source:q.source,named:[],namedTypes:[],original:""};K.type.namedTypes=K.type.namedTypes.concat(q.namedTypes)}}A.set(q.source,K)}let B=[];for(let[q,K]of A){if(K.side)B.push(...K.side);if(K.value){let N=(O)=>{if(!O.alias)return O;return/^[A-Z]$/i.test(O.name)&&/^[A-Z]$/i.test(O.alias)?{name:O.alias,alias:O.name}:O};K.value.named=K.value.named.map(N),K.value.named.sort((O,y)=>O.name.localeCompare(y.name)),B.push(K.value)}if(K.type&&K.type.namedTypes.length>0){let N=new Set,O=(y)=>{if(!y.alias)return y;return/^[A-Z]$/i.test(y.name)&&/^[A-Z]$/i.test(y.alias)?{name:y.alias,alias:y.name}:y};K.type.namedTypes=K.type.namedTypes.map(O).filter((y)=>{let w=`${y.name}|${y.alias||""}`;if(N.has(w))return!1;return N.add(w),!0}),K.type.namedTypes.sort((y,w)=>y.name.localeCompare(w.name)),B.push(K.type)}}let j=(q)=>q.startsWith(".")?2:q.startsWith("node:")?0:1,I=(q)=>{if(q.kind!=="value")return 99;if(q.defaultName)return 0;if(q.namespaceName)return 1;return 2};B.sort((q,K)=>{if(q.kind!==K.kind){if(q.kind==="type")return-1;if(K.kind==="type")return 1;if(q.kind==="side-effect")return-1;if(K.kind==="side-effect")return 1}if(q.kind==="type"&&K.kind==="type"){let N=j(q.source),O=j(K.source);if(N!==O)return N-O;return q.source.localeCompare(K.source)}if(q.kind==="value"&&K.kind==="value"){let N=j(q.source),O=j(K.source);if(N!==O)return N-O;let y=I(q),w=I(K);if(y!==w)return y-w;return q.source.localeCompare(K.source)}return q.source.localeCompare(K.source)});let R=X.length>0?`${X.join(`
|
|
23
23
|
`)}
|
|
24
|
-
`:"";if(B.length===0){let q=G.replace(/^\n+/,""),K=[...J];if(
|
|
24
|
+
`:"";if(B.length===0){let q=G.replace(/^\n+/,""),K=[...J];if(R||K.length>0)return`${R}${K.length>0?`${K.join(`
|
|
25
25
|
`)}
|
|
26
|
-
`:""}${q}`;return q}let
|
|
27
|
-
`),
|
|
26
|
+
`:""}${q}`;return q}let C=B.map(U0).join(`
|
|
27
|
+
`),E=J.length>0?`
|
|
28
28
|
${J.join(`
|
|
29
|
-
`)}`:"",
|
|
29
|
+
`)}`:"",L=G.replace(/^\n+/,""),WZ=L.length>0?`
|
|
30
30
|
|
|
31
31
|
`:`
|
|
32
|
-
`;return`${_}${L}${S}${WZ}${d}`}function U0($){if($.kind==="side-effect")return`import '${$.source}'`;if($.kind==="type")return`import type { ${$.namedTypes.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ")} } from '${$.source}'`;let Y=[];if($.defaultName)Y.push($.defaultName);if($.namespaceName)Y.push(`* as ${$.namespaceName}`);if($.named.length>0){let Z=$.named.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ");Y.push(`{ ${Z} }`)}return`import ${Y.join(", ")} from '${$.source}'`}function W0($){let Y=$.match(/^\s*import\s+['"]([^'"]+)['"]/);if(Y)return{kind:"side-effect",source:Y[1],named:[],namedTypes:[],original:$};if(Y=$.match(/^\s*import\s+type\s+\{([^}]*)\}\s+from\s+['"]([^'"]+)['"]/),Y){let W=Y[1],D=Y[2],M=W.split(",").map((A)=>A.trim()).filter(Boolean).map((A)=>{let B=A.match(/^(\w+)(?:\s+as\s+(\w+))?$/);return{name:B?.[1]||A,alias:B?.[2]}});return{kind:"type",source:D,named:[],namedTypes:M,original:$}}let V=$.match(/^\s*import\s+/),Z=new RegExp(`\\sfrom\\s+['"]([^'"]+)['"]\\s*;?$`),X=$.match(Z);if(!V||!X)return;let J=X[1],H=$.slice(V[0].length,X.index).trim(),U,Q,F=[],z=[],G=H.match(/\{([^}]*)\}/);if(G){let D=G[1].split(",").map((M)=>M.trim()).filter(Boolean);for(let M of D){let A=/^type\s+/.test(M),N=M.replace(/^type\s+/,"").match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!N)continue;let j={name:N[1],alias:N[2]};if(A)z.push(j);else F.push(j)}H=H.replace(/\{[\s\S]*?\}/,"").trim()}if(H.length>0){let W=H.split(",").map((D)=>D.trim()).filter(Boolean);for(let D of W)if(D.startsWith("* as "))Q=D.slice(5).trim();else if(/^\w+$/.test(D))U=D}return{kind:"value",source:J,defaultName:U,namespaceName:Q,named:F,namedTypes:z,original:$}}function q0($,Y){if(fZ.test(Y))return Q0($);if(hZ.test(Y))return K0($);return null}function YZ($){try{return JSON.parse($)}catch{return null}}function E($,Y,V=[]){let Z={};for(let J of Y)if(Object.prototype.hasOwnProperty.call($,J))Z[J]=$[J];for(let J of V){let H=Object.keys($).filter((U)=>J.test(U)&&!(U in Z)).sort();for(let U of H)Z[U]=$[U]}let X=Object.keys($).filter((J)=>!(J in Z)).sort();for(let J of X)Z[J]=$[J];return Z}function i($){let Y={};for(let V of Object.keys($).sort())Y[V]=$[V];return Y}function Q0($){let Y=YZ($);if(!Y||typeof Y!=="object")return $;let Z=E(Y,["publisher","name","displayName","type","version","private","packageManager","description","author","contributors","license","funding","homepage","repository","bugs","keywords","categories","sideEffects","imports","exports","main","module","unpkg","jsdelivr","types","typesVersions","bin","icon","files","engines","activationEvents","contributes","scripts","peerDependencies","peerDependenciesMeta","dependencies","optionalDependencies","devDependencies","pnpm","overrides","resolutions","husky","simple-git-hooks","lint-staged","eslintConfig"]);if(Array.isArray(Z.files)){if(Z.files.every((H)=>typeof H==="string"))Z.files=[...Z.files].sort()}for(let J of Object.keys(Z))if(/^(?:dev|peer|optional|bundled)?[Dd]ependencies(?:Meta)?$/.test(J)||/^(?:resolutions|overrides|pnpm\.overrides)$/.test(J)){if(Z[J]&&typeof Z[J]==="object")Z[J]=i(Z[J])}if(Z.pnpm&&typeof Z.pnpm==="object"&&Z.pnpm.overrides&&typeof Z.pnpm.overrides==="object")Z.pnpm.overrides=i(Z.pnpm.overrides);if(Z.exports&&typeof Z.exports==="object"){let J=Z.exports,H=["types","import","require","default"];if(!Array.isArray(J)){let U={};for(let Q of Object.keys(J)){let F=J[Q];if(F&&typeof F==="object"&&!Array.isArray(F))U[Q]=E(F,H);else U[Q]=F}Z.exports=U}}let X=["pre-commit","prepare-commit-msg","commit-msg","post-commit","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"];for(let J of["gitHooks","husky","simple-git-hooks"])if(Z[J]&&typeof Z[J]==="object")Z[J]=E(Z[J],X);return JSON.stringify(Z,null,2)}function K0($){let Y=YZ($);if(!Y||typeof Y!=="object")return $;let Z=E(Y,["extends","compilerOptions","references","files","include","exclude"]);if(Z.compilerOptions&&typeof Z.compilerOptions==="object"){let X=["incremental","composite","tsBuildInfoFile","disableSourceOfProjectReferenceRedirect","disableSolutionSearching","disableReferencedProjectLoad","target","jsx","jsxFactory","jsxFragmentFactory","jsxImportSource","lib","moduleDetection","noLib","reactNamespace","useDefineForClassFields","emitDecoratorMetadata","experimentalDecorators","libReplacement","baseUrl","rootDir","rootDirs","customConditions","module","moduleResolution","moduleSuffixes","noResolve","paths","resolveJsonModule","resolvePackageJsonExports","resolvePackageJsonImports","typeRoots","types","allowArbitraryExtensions","allowImportingTsExtensions","allowUmdGlobalAccess","allowJs","checkJs","maxNodeModuleJsDepth","strict","strictBindCallApply","strictFunctionTypes","strictNullChecks","strictPropertyInitialization","allowUnreachableCode","allowUnusedLabels","alwaysStrict","exactOptionalPropertyTypes","noFallthroughCasesInSwitch","noImplicitAny","noImplicitOverride","noImplicitReturns","noImplicitThis","noPropertyAccessFromIndexSignature","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","useUnknownInCatchVariables","declaration","declarationDir","declarationMap","downlevelIteration","emitBOM","emitDeclarationOnly","importHelpers","importsNotUsedAsValues","inlineSourceMap","inlineSources","mapRoot","newLine","noEmit","noEmitHelpers","noEmitOnError","outDir","outFile","preserveConstEnums","preserveValueImports","removeComments","sourceMap","sourceRoot","stripInternal","allowSyntheticDefaultImports","esModuleInterop","forceConsistentCasingInFileNames","isolatedDeclarations","isolatedModules","preserveSymlinks","verbatimModuleSyntax","erasableSyntaxOnly","skipDefaultLibCheck","skipLibCheck"];Z.compilerOptions=E(Z.compilerOptions,X)}return JSON.stringify(Z,null,2)}import{readdirSync as z0,readFileSync as B0,statSync as HZ}from"fs";import{extname as G0,isAbsolute as m,join as u,resolve as D0}from"path";import R from"process";var f0=5;function y0($){let Y="",V=0;while(V<$.length){let Z=$[V];if(Z==="*")if($[V+1]==="*"){if(Y+=".*",V+=2,$[V]==="/")V++}else Y+="[^/]*",V++;else if(Z==="?")Y+="[^/]",V++;else if(Z==="["){let X=$.indexOf("]",V);if(X===-1)Y+="\\[",V++;else Y+=$.slice(V,X+1),V=X+1}else if(".+^${}()|\\".includes(Z))Y+=`\\${Z}`,V++;else Y+=Z,V++}return new RegExp(`^${Y}$`)}function*UZ($,Y,V){let Z;try{Z=z0($)}catch{return}for(let X of Z){if(!V&&X.startsWith("."))continue;let J=u($,X);if(Y(J))continue;let H;try{H=HZ(J)}catch{continue}if(H.isDirectory())yield*UZ(J,Y,V);else yield J}}function*JZ($,Y,V,Z){yield*UZ($,p(Y,Z),V)}async function h0($,Y={}){let V=Y.cwd??R.cwd(),Z=Y.ignore??[],X=Y.dot??!1,J=Y.absolute??!0,H=p(Z,V);if(typeof globalThis.Bun?.Glob<"u"){let Q=globalThis.Bun.Glob,F=[];for(let z of $){let G=new Q(z);for await(let W of G.scan({cwd:V,dot:X,onlyFiles:Y.onlyFiles??!0,followSymlinks:!1})){let D=m(W)?W:u(V,W),M=D.startsWith(`${V}/`)?D.slice(V.length+1):D;if(H(D))continue;F.push(J?D:M)}}return F}let U=[];for(let Q of $){if(!/[*?[{]/.test(Q)){let z=m(Q)?Q:u(V,Q);try{if(!HZ(z).isDirectory()){let W=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(!H(z))U.push(J?z:W)}else for(let W of JZ(z,Z,X,V))U.push(J?W:W.startsWith(`${V}/`)?W.slice(V.length+1):W)}catch{}continue}let F=y0(Q);for(let z of JZ(V,Z,X,V)){let G=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(F.test(G)||F.test(G.replace(/\\/g,"/")))U.push(J?z:G)}}return U}function g0($){let Y=0,V=[],Z=()=>{if(V.length>0&&Y<$)Y++,V.shift()()};return(X)=>{return new Promise((J,H)=>{let U=()=>{X().then((Q)=>{Y--,J(Q),Z()},(Q)=>{Y--,H(Q),Z()})};if(Y<$)Y++,U();else V.push(U)})}}var M0={get TRACE(){return R.env.PICKIER_TRACE==="1"},get TIMEOUT_MS(){return Number(R.env.PICKIER_TIMEOUT_MS||"8000")},get RULE_TIMEOUT_MS(){return Number(R.env.PICKIER_RULE_TIMEOUT_MS||"5000")},get CONCURRENCY(){return Number(R.env.PICKIER_CONCURRENCY)||8},get DIAGNOSTICS(){return R.env.PICKIER_DIAGNOSTICS==="1"},get FAIL_ON_WARNINGS(){return R.env.PICKIER_FAIL_ON_WARNINGS==="1"},get NO_AUTO_CONFIG(){return R.env.PICKIER_NO_AUTO_CONFIG==="1"}},A0=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.vercel/**","**/.netlify/**","**/.cache/**","**/.turbo/**","**/.vscode/**","**/.idea/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/coverage/**","**/.nyc_output/**","**/.tmp/**","**/.temp/**","**/vendor/**","**/pantry/**","**/target/**","**/zig-cache/**","**/zig-out/**","**/.zig-cache/**","**/__pycache__/**","**/.pytest_cache/**","**/venv/**","**/.venv/**","**/out/**","**/.DS_Store","**/Thumbs.db"];function m0($,Y){let V=$[Y];if(V===void 0){let J=Y.indexOf("/");if(J>0){let H=Y.slice(0,J),U=Y.slice(J+1),Q=H==="general"?"pickier":H==="pickier"?"general":null;if(Q)V=$[`${Q}/${U}`];if(V===void 0)V=$[U]}}let Z,X;if(typeof V==="string"){if(V==="error")Z="error";else if(V==="warn"||V==="warning")Z="warning"}else if(Array.isArray(V)&&typeof V[0]==="string"){let J=V[0];if(J==="error")Z="error";else if(J==="warn"||J==="warning")Z="warning";X=V[1]}return{enabled:!!Z,severity:Z,options:X}}function T($,Y){return`\x1B[${$}m${Y}\x1B[0m`}function O0($){return T("32",$)}function N0($){return T("31",$)}function j0($){return T("33",$)}function w0($){return T("34",$)}function I0($){return T("90",$)}function R0($){return T("1",$)}var u0={green:O0,red:N0,yellow:j0,blue:w0,gray:I0,bold:R0};function v($,Y){let V=Y.ignores?[...new Set([...$.ignores||[],...Y.ignores])]:$.ignores,Z={...$.pluginRules||{},...Y.pluginRules||{}};if((Y.tailwind??$.tailwind)?.enabled&&!Object.prototype.hasOwnProperty.call(Z,"pickier/sort-tailwind-classes"))Z["pickier/sort-tailwind-classes"]="warn";return{...$,...Y,verbose:Y.verbose??$.verbose,ignores:V,lint:{...$.lint,...Y.lint||{}},format:{...$.format,...Y.format||{}},rules:{...$.rules,...Y.rules||{}},pluginRules:Z}}var g=null;async function c0($){if(!$){if(M0.NO_AUTO_CONFIG){if(!g)g=v(P,{});return g}try{let{getConfig:Z}=await import("./chunk-nwytx79z.js"),X=await Z();return v(P,X)}catch{}return v(P,{})}let Y=m($)?$:D0(R.cwd(),$);if(G0(Y).toLowerCase()===".json")try{let Z=B0(Y,"utf8");return v(P,JSON.parse(Z))}catch{return console.warn(`[pickier:warn] Config file not found: ${Y}. Using default config values.`),v(P,{})}try{let Z=await import(Y);return v(P,Z.default||Z)}catch{return console.warn(`[pickier:warn] Config file not found: ${Y}. Using default config values.`),v(P,{})}}function p0($){return $.map((Y)=>{if(/[*?[\]{}()!]/.test(Y))return Y;if(/\.[A-Z0-9]+$/i.test(Y))return Y;return`${Y.replace(/\/$/,"")}/**/*`})}function d0($,Y){let V=$.lastIndexOf(".");if(V<0)return!1;let Z=$.slice(V);return Y.has(Z)}function c($){return $.replace(/\\/g,"/").replace(/\/+/g,"/")}function L0($){let Y=[];for(let V of $){let Z=c(V.trim());if(!Z)continue;let X=Z.match(/\*\*\/\*\.(.+)$/);if(X){Y.push({raw:Z,kind:"extension",value:X[1]});continue}let J=Z.match(/\*\*\/(.+?)\/\*\*$/);if(J){Y.push({raw:Z,kind:"segment",value:J[1]});continue}let H=Z.match(/\*\*\/(.+)$/);if(H)Y.push({raw:Z,kind:"suffix",value:H[1].replace(/\/$/,"")})}return Y}function p($,Y=R.cwd()){if($.length===0)return()=>!1;let V=L0($);if(V.length===0)return()=>!1;let Z=new Set(A0);return(X)=>{let J=c(X),H=c(Y).replace(/\/$/,""),U=J!==H&&!J.startsWith(`${H}/`),Q=U?J:J.slice(H.length);for(let F of V){if(U&&!Z.has(F.raw))continue;if(F.kind==="extension"){if(Q.endsWith(`.${F.value}`))return!0;continue}if(F.kind==="segment"||F.kind==="suffix"){let z=F.value;if(Q.includes(`/${z}/`)||Q.endsWith(`/${z}`))return!0}}return!1}}function o0($,Y){return p(Y)($)}
|
|
33
|
-
export{qZ as i,o as j,_0 as k,T0 as l,C0 as m,H0 as n,f0 as o,h0 as p,g0 as q,M0 as r,A0 as s,m0 as t,T as u,O0 as v,N0 as w,j0 as x,
|
|
32
|
+
`;return`${R}${C}${E}${WZ}${L}`}function U0($){if($.kind==="side-effect")return`import '${$.source}'`;if($.kind==="type")return`import type { ${$.namedTypes.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ")} } from '${$.source}'`;let Y=[];if($.defaultName)Y.push($.defaultName);if($.namespaceName)Y.push(`* as ${$.namespaceName}`);if($.named.length>0){let Z=$.named.map((X)=>X.alias?`${X.name} as ${X.alias}`:X.name).join(", ");Y.push(`{ ${Z} }`)}return`import ${Y.join(", ")} from '${$.source}'`}function W0($){let Y=$.match(/^\s*import\s+['"]([^'"]+)['"]/);if(Y)return{kind:"side-effect",source:Y[1],named:[],namedTypes:[],original:$};if(Y=$.match(/^\s*import\s+type\s+\{([^}]*)\}\s+from\s+['"]([^'"]+)['"]/),Y){let W=Y[1],D=Y[2],M=W.split(",").map((A)=>A.trim()).filter(Boolean).map((A)=>{let B=A.match(/^(\w+)(?:\s+as\s+(\w+))?$/);return{name:B?.[1]||A,alias:B?.[2]}});return{kind:"type",source:D,named:[],namedTypes:M,original:$}}let V=$.match(/^\s*import\s+/),Z=new RegExp(`\\sfrom\\s+['"]([^'"]+)['"]\\s*;?$`),X=$.match(Z);if(!V||!X)return;let J=X[1],H=$.slice(V[0].length,X.index).trim(),U,Q,F=[],z=[],G=H.match(/\{([^}]*)\}/);if(G){let D=G[1].split(",").map((M)=>M.trim()).filter(Boolean);for(let M of D){let A=/^type\s+/.test(M),j=M.replace(/^type\s+/,"").match(/^(\w+)(?:\s+as\s+(\w+))?$/);if(!j)continue;let I={name:j[1],alias:j[2]};if(A)z.push(I);else F.push(I)}H=H.replace(/\{[\s\S]*?\}/,"").trim()}if(H.length>0){let W=H.split(",").map((D)=>D.trim()).filter(Boolean);for(let D of W)if(D.startsWith("* as "))Q=D.slice(5).trim();else if(/^\w+$/.test(D))U=D}return{kind:"value",source:J,defaultName:U,namespaceName:Q,named:F,namedTypes:z,original:$}}function q0($,Y){if(fZ.test(Y))return Q0($);if(hZ.test(Y))return K0($);return null}function YZ($){try{return JSON.parse($)}catch{return null}}function k($,Y,V=[]){let Z={};for(let J of Y)if(Object.prototype.hasOwnProperty.call($,J))Z[J]=$[J];for(let J of V){let H=Object.keys($).filter((U)=>J.test(U)&&!(U in Z)).sort();for(let U of H)Z[U]=$[U]}let X=Object.keys($).filter((J)=>!(J in Z)).sort();for(let J of X)Z[J]=$[J];return Z}function i($){let Y={};for(let V of Object.keys($).sort())Y[V]=$[V];return Y}function Q0($){let Y=YZ($);if(!Y||typeof Y!=="object")return $;let Z=k(Y,["publisher","name","displayName","type","version","private","packageManager","description","author","contributors","license","funding","homepage","repository","bugs","keywords","categories","sideEffects","imports","exports","main","module","unpkg","jsdelivr","types","typesVersions","bin","icon","files","engines","activationEvents","contributes","scripts","peerDependencies","peerDependenciesMeta","dependencies","optionalDependencies","devDependencies","pnpm","overrides","resolutions","husky","simple-git-hooks","lint-staged","eslintConfig"]);if(Array.isArray(Z.files)){if(Z.files.every((H)=>typeof H==="string"))Z.files=[...Z.files].sort()}for(let J of Object.keys(Z))if(/^(?:dev|peer|optional|bundled)?[Dd]ependencies(?:Meta)?$/.test(J)||/^(?:resolutions|overrides|pnpm\.overrides)$/.test(J)){if(Z[J]&&typeof Z[J]==="object")Z[J]=i(Z[J])}if(Z.pnpm&&typeof Z.pnpm==="object"&&Z.pnpm.overrides&&typeof Z.pnpm.overrides==="object")Z.pnpm.overrides=i(Z.pnpm.overrides);if(Z.exports&&typeof Z.exports==="object"){let J=Z.exports,H=["types","import","require","default"];if(!Array.isArray(J)){let U={};for(let Q of Object.keys(J)){let F=J[Q];if(F&&typeof F==="object"&&!Array.isArray(F))U[Q]=k(F,H);else U[Q]=F}Z.exports=U}}let X=["pre-commit","prepare-commit-msg","commit-msg","post-commit","pre-rebase","post-rewrite","post-checkout","post-merge","pre-push","pre-auto-gc"];for(let J of["gitHooks","husky","simple-git-hooks"])if(Z[J]&&typeof Z[J]==="object")Z[J]=k(Z[J],X);return JSON.stringify(Z,null,2)}function K0($){let Y=YZ($);if(!Y||typeof Y!=="object")return $;let Z=k(Y,["extends","compilerOptions","references","files","include","exclude"]);if(Z.compilerOptions&&typeof Z.compilerOptions==="object"){let X=["incremental","composite","tsBuildInfoFile","disableSourceOfProjectReferenceRedirect","disableSolutionSearching","disableReferencedProjectLoad","target","jsx","jsxFactory","jsxFragmentFactory","jsxImportSource","lib","moduleDetection","noLib","reactNamespace","useDefineForClassFields","emitDecoratorMetadata","experimentalDecorators","libReplacement","baseUrl","rootDir","rootDirs","customConditions","module","moduleResolution","moduleSuffixes","noResolve","paths","resolveJsonModule","resolvePackageJsonExports","resolvePackageJsonImports","typeRoots","types","allowArbitraryExtensions","allowImportingTsExtensions","allowUmdGlobalAccess","allowJs","checkJs","maxNodeModuleJsDepth","strict","strictBindCallApply","strictFunctionTypes","strictNullChecks","strictPropertyInitialization","allowUnreachableCode","allowUnusedLabels","alwaysStrict","exactOptionalPropertyTypes","noFallthroughCasesInSwitch","noImplicitAny","noImplicitOverride","noImplicitReturns","noImplicitThis","noPropertyAccessFromIndexSignature","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","useUnknownInCatchVariables","declaration","declarationDir","declarationMap","downlevelIteration","emitBOM","emitDeclarationOnly","importHelpers","importsNotUsedAsValues","inlineSourceMap","inlineSources","mapRoot","newLine","noEmit","noEmitHelpers","noEmitOnError","outDir","outFile","preserveConstEnums","preserveValueImports","removeComments","sourceMap","sourceRoot","stripInternal","allowSyntheticDefaultImports","esModuleInterop","forceConsistentCasingInFileNames","isolatedDeclarations","isolatedModules","preserveSymlinks","verbatimModuleSyntax","erasableSyntaxOnly","skipDefaultLibCheck","skipLibCheck"];Z.compilerOptions=k(Z.compilerOptions,X)}return JSON.stringify(Z,null,2)}import{readdirSync as z0,readFileSync as B0,statSync as HZ}from"fs";import{extname as G0,isAbsolute as u,join as c,resolve as D0}from"path";import v from"process";var f0=5;function y0($){let Y="",V=0;while(V<$.length){let Z=$[V];if(Z==="*")if($[V+1]==="*"){if(Y+=".*",V+=2,$[V]==="/")V++}else Y+="[^/]*",V++;else if(Z==="?")Y+="[^/]",V++;else if(Z==="["){let X=$.indexOf("]",V);if(X===-1)Y+="\\[",V++;else Y+=$.slice(V,X+1),V=X+1}else if(".+^${}()|\\".includes(Z))Y+=`\\${Z}`,V++;else Y+=Z,V++}return new RegExp(`^${Y}$`)}function*UZ($,Y,V){let Z;try{Z=z0($)}catch{return}for(let X of Z){if(!V&&X.startsWith("."))continue;let J=c($,X);if(Y(J))continue;let H;try{H=HZ(J)}catch{continue}if(H.isDirectory())yield*UZ(J,Y,V);else yield J}}function*JZ($,Y,V,Z){yield*UZ($,d(Y,Z),V)}async function h0($,Y={}){let V=Y.cwd??v.cwd(),Z=Y.ignore??[],X=Y.dot??!1,J=Y.absolute??!0,H=d(Z,V);if(typeof globalThis.Bun?.Glob<"u"){let Q=globalThis.Bun.Glob,F=[];for(let z of $){let G=new Q(z);for await(let W of G.scan({cwd:V,dot:X,onlyFiles:Y.onlyFiles??!0,followSymlinks:!1})){let D=u(W)?W:c(V,W),M=D.startsWith(`${V}/`)?D.slice(V.length+1):D;if(H(D))continue;F.push(J?D:M)}}return F}let U=[];for(let Q of $){if(!/[*?[{]/.test(Q)){let z=u(Q)?Q:c(V,Q);try{if(!HZ(z).isDirectory()){let W=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(!H(z))U.push(J?z:W)}else for(let W of JZ(z,Z,X,V))U.push(J?W:W.startsWith(`${V}/`)?W.slice(V.length+1):W)}catch{}continue}let F=y0(Q);for(let z of JZ(V,Z,X,V)){let G=z.startsWith(`${V}/`)?z.slice(V.length+1):z;if(F.test(G)||F.test(G.replace(/\\/g,"/")))U.push(J?z:G)}}return U}function g0($){let Y=0,V=[],Z=()=>{if(V.length>0&&Y<$)Y++,V.shift()()};return(X)=>{return new Promise((J,H)=>{let U=()=>{X().then((Q)=>{Y--,J(Q),Z()},(Q)=>{Y--,H(Q),Z()})};if(Y<$)Y++,U();else V.push(U)})}}var M0={get TRACE(){return v.env.PICKIER_TRACE==="1"},get TIMEOUT_MS(){return Number(v.env.PICKIER_TIMEOUT_MS||"8000")},get RULE_TIMEOUT_MS(){return Number(v.env.PICKIER_RULE_TIMEOUT_MS||"5000")},get CONCURRENCY(){return Number(v.env.PICKIER_CONCURRENCY)||8},get DIAGNOSTICS(){return v.env.PICKIER_DIAGNOSTICS==="1"},get FAIL_ON_WARNINGS(){return v.env.PICKIER_FAIL_ON_WARNINGS==="1"},get NO_AUTO_CONFIG(){return v.env.PICKIER_NO_AUTO_CONFIG==="1"}},A0=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.vercel/**","**/.netlify/**","**/.cache/**","**/.turbo/**","**/.vscode/**","**/.idea/**","**/.zed/**","**/.cursor/**","**/.claude/**","**/.github/**","**/coverage/**","**/.nyc_output/**","**/.tmp/**","**/.temp/**","**/vendor/**","**/pantry/**","**/target/**","**/zig-cache/**","**/zig-out/**","**/.zig-cache/**","**/__pycache__/**","**/.pytest_cache/**","**/venv/**","**/.venv/**","**/out/**","**/.DS_Store","**/Thumbs.db"];function m0($,Y){let V=$[Y];if(V===void 0){let J=Y.indexOf("/");if(J>0){let H=Y.slice(0,J),U=Y.slice(J+1),Q=H==="general"?"pickier":H==="pickier"?"general":null;if(Q)V=$[`${Q}/${U}`];if(V===void 0)V=$[U]}}let Z,X;if(typeof V==="string"){if(V==="error")Z="error";else if(V==="warn"||V==="warning")Z="warning"}else if(Array.isArray(V)&&typeof V[0]==="string"){let J=V[0];if(J==="error")Z="error";else if(J==="warn"||J==="warning")Z="warning";X=V[1]}return{enabled:!!Z,severity:Z,options:X}}function T($,Y){return`\x1B[${$}m${Y}\x1B[0m`}function O0($){return T("32",$)}function N0($){return T("31",$)}function j0($){return T("33",$)}function I0($){return T("34",$)}function R0($){return T("90",$)}function w0($){return T("1",$)}var u0={green:O0,red:N0,yellow:j0,blue:I0,gray:R0,bold:w0};function _($,Y){let V=Y.ignores?[...new Set([...$.ignores||[],...Y.ignores])]:$.ignores,Z={...$.pluginRules||{},...Y.pluginRules||{}};if((Y.tailwind??$.tailwind)?.enabled&&!Object.prototype.hasOwnProperty.call(Z,"pickier/sort-tailwind-classes"))Z["pickier/sort-tailwind-classes"]="warn";return{...$,...Y,verbose:Y.verbose??$.verbose,ignores:V,lint:{...$.lint,...Y.lint||{}},format:{...$.format,...Y.format||{}},rules:{...$.rules,...Y.rules||{}},pluginRules:Z}}var m=null;async function c0($){if(!$){if(M0.NO_AUTO_CONFIG){if(!m)m=_(P,{});return m}try{let{getConfig:Z}=await import("./chunk-jtgkwhm9.js"),X=await Z();return _(P,X)}catch{}return _(P,{})}let Y=u($)?$:D0(v.cwd(),$);if(G0(Y).toLowerCase()===".json")try{let Z=B0(Y,"utf8");return _(P,JSON.parse(Z))}catch{return console.warn(`[pickier:warn] Config file not found: ${Y}. Using default config values.`),_(P,{})}try{let Z=await import(Y);return _(P,Z.default||Z)}catch{return console.warn(`[pickier:warn] Config file not found: ${Y}. Using default config values.`),_(P,{})}}function p0($){return $.map((Y)=>{if(/[*?[\]{}()!]/.test(Y))return Y;if(/\.[A-Z0-9]+$/i.test(Y))return Y;return`${Y.replace(/\/$/,"")}/**/*`})}function d0($,Y){let V=$.lastIndexOf(".");if(V<0)return!1;let Z=$.slice(V);return Y.has(Z)}function p($){return $.replace(/\\/g,"/").replace(/\/+/g,"/")}function L0($){let Y=[];for(let V of $){let Z=p(V.trim());if(!Z)continue;let X=Z.match(/\*\*\/\*\.(.+)$/);if(X){Y.push({raw:Z,kind:"extension",value:X[1]});continue}let J=Z.match(/\*\*\/(.+?)\/\*\*$/);if(J){Y.push({raw:Z,kind:"segment",value:J[1]});continue}let H=Z.match(/\*\*\/(.+)$/);if(H)Y.push({raw:Z,kind:"suffix",value:H[1].replace(/\/$/,"")})}return Y}function d($,Y=v.cwd()){if($.length===0)return()=>!1;let V=L0($);if(V.length===0)return()=>!1;let Z=new Set(A0);return(X)=>{let J=p(X),H=p(Y).replace(/\/$/,""),U=J!==H&&!J.startsWith(`${H}/`),Q=U?J:J.slice(H.length);for(let F of V){if(U&&!Z.has(F.raw))continue;if(F.kind==="extension"){if(Q.endsWith(`.${F.value}`))return!0;continue}if(F.kind==="segment"||F.kind==="suffix"){let z=F.value;if(Q.includes(`/${z}/`)||Q.endsWith(`/${z}`))return!0}}return!1}}function o0($,Y){return d(Y)($)}
|
|
33
|
+
export{qZ as i,o as j,_0 as k,T0 as l,C0 as m,H0 as n,f0 as o,h0 as p,g0 as q,M0 as r,A0 as s,m0 as t,T as u,O0 as v,N0 as w,j0 as x,I0 as y,R0 as z,w0 as A,u0 as B,_ as C,c0 as D,p0 as E,d0 as F,d as G,o0 as H};
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as t,b as f,c as m,g as e}from"../chunk-
|
|
2
|
+
import{a as t,b as f,c as m,g as e}from"../chunk-kd24156y.js";import{h as x}from"../chunk-hd1a5cpg.js";import{A as F,B as G,C as H,D as I,E as J,F as K,G as M,H as N,k as O,l as P,m as R,n as T,o as U,p as a,q as b,r as j,s as q,t as v,u as w,v as z,w as A,x as B,y as D,z as E}from"../chunk-y0y1q8bv.js";import{I as r,K as o}from"../chunk-sa6phv2n.js";import"../chunk-h6ac3d60.js";export{B as yellow,N as shouldIgnorePath,m as runLintProgrammatic,e as runLint,t as runFormat,x as run,A as red,H as mergeConfig,I as loadConfigFromPath,f as lintText,K as isCodeFile,R as hasIndentIssue,z as green,E as gray,a as glob,v as getRuleSetting,T as formatImports,O as formatCode,J as expandPatterns,P as detectQuoteIssues,r as defaultConfig,b as createLimiter,M as createIgnoreMatcher,o as config,G as colors,w as colorize,F as bold,D as blue,q as UNIVERSAL_IGNORES,U as MAX_FIXER_PASSES,j as ENV};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
package/dist/chunk-p4y6z6j6.js
DELETED