1ls 0.1.2 → 0.1.3
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/README.md +3 -3
- package/dist/index.js +19 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ bun add -g 1ls
|
|
|
37
37
|
|
|
38
38
|
# Or via binaries. here you get a QuickJs build
|
|
39
39
|
# Using Homebrew (macOS/Linux)
|
|
40
|
-
brew install yowainwright/
|
|
40
|
+
brew install yowainwright/tap/1ls
|
|
41
41
|
# Using curl
|
|
42
42
|
curl -fsSL https://raw.githubusercontent.com/yowainwright/1ls/main/scripts/install.sh | bash
|
|
43
43
|
```
|
|
@@ -284,8 +284,8 @@ echo '["a", "b"]' | 1ls '.jn(",")' # Short for .join()
|
|
|
284
284
|
| `--version` | `-v` | Show version |
|
|
285
285
|
| `--interactive` | | Interactive fuzzy search explorer |
|
|
286
286
|
| `--raw` | `-r` | Output raw strings, not JSON |
|
|
287
|
-
| `--pretty` | `-p` | Pretty print output |
|
|
288
|
-
| `--compact` | `-c` | Compact output |
|
|
287
|
+
| `--pretty` | `-p` | Pretty print output (default) |
|
|
288
|
+
| `--compact` | `-c` | Compact single-line output |
|
|
289
289
|
| `--type` | `-t` | Show type of result |
|
|
290
290
|
|
|
291
291
|
### Format Options
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var br=Object.defineProperty;var O=(t,e)=>{for(var n in e)br(t,n,{get:e[n],enumerable:!0,configurable:!0,set:(r)=>e[n]=()=>r})};var x=(t,e)=>()=>(t&&(e=t(t=0)),e);var Sr,wr,Er,Ar,Ne,Tr,Nr,Or,vr,Ir,Cr,
|
|
4
|
-
`);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=
|
|
3
|
+
var br=Object.defineProperty;var O=(t,e)=>{for(var n in e)br(t,n,{get:e[n],enumerable:!0,configurable:!0,set:(r)=>e[n]=()=>r})};var x=(t,e)=>()=>(t&&(e=t(t=0)),e);var Sr,wr,Er,Ar,Ne,Tr,Nr,Or,vr,Ir,Rr,Cr,Fr,Mr,Lr,kr,Pr,_r,Br,Ft,Mt,M,Oe,Lt,jr,Dr,Vr,$r,Gr,Wr,E;var V=x(()=>{Sr=/^-?\d+$/,wr=/^[+-]?\d+$/,Er=/^-?\d+\.\d+$/,Ar=/^[+-]?\d+\.\d+$/,Ne=/^-?\d+(\.\d+)?$/,Tr=/(\w+)=["']([^"']+)["']/g,Nr=/^<(\w+)([^>]*?)\/>/,Or=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,vr=/<\w+/,Ir=/<\/\w+>$/,Rr=/^<\?xml[^>]+\?>\s*/,Cr=/,(\s*[}\]])/g,Fr=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,Mr=/\/\/|\/\*|,\s*[}\]]/,Lr=/^\[[\w.\s]+\]$/m,kr=/^\[[\w.]+\]$/m,Pr=/^\w+\s*=\s*"[^"]*"$/m,_r=/=\s*["[{]/m,Br=/^\w+\s*=\s*.+$/m,Ft={INTEGER:Sr,FLOAT:Er},Mt={INTEGER:wr,FLOAT:Ar},M={NUMBER:Ne,ATTRIBUTES:Tr,SELF_CLOSING:Nr,OPEN_TAG:Or,NESTED_TAGS:vr,COMPLETE_TAGS:Ir,XML_DECLARATION:Rr},Oe={NUMBER:Ne},Lt={TRAILING_COMMA:Cr,UNQUOTED_KEY:Fr},jr=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,Dr=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,Vr=/^\s*interface\s+\w+/m,$r=/^\s*type\s+\w+\s*=/m,Gr=/^[A-Z_][A-Z0-9_]*\s*=/m,Wr=/^\{.*\}\s*$/m,E={JSON5_FEATURES:Mr,SECTION_HEADER:Lr,TOML_SECTION:kr,TOML_QUOTED_VALUES:Pr,TOML_SYNTAX:_r,INI_SYNTAX:Br,JS_EXPORT:jr,TS_TYPE_ANNOTATION:Dr,TS_INTERFACE:Vr,TS_TYPE_ALIAS:$r,ENV_FEATURES:Gr,NDJSON_FEATURES:Wr}});var ke={};O(ke,{stripJSON5Comments:()=>Me,parseJSON5:()=>Ur,normalizeJSON5:()=>Le,isQuoteChar:()=>ve,handleStringChar:()=>Ce,handleNormalChar:()=>Fe,findMultiLineCommentEnd:()=>Re,findCommentEnd:()=>Ie});function ve(t){return t==='"'||t==="'"}function Ie(t,e,n){let o=t.slice(e).findIndex((i)=>i===n);return o===-1?t.length-e:o}function Re(t,e){let n=2,r=t.length-e;while(n<r){let o=t[e+n],s=t[e+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function Ce(t,e,n){if(t.result.push(e),e==="\\"&&n)return t.result.push(n),{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:1};if(e===t.delimiter)return{result:t.result,inString:!1,delimiter:"",skip:0};return t}function Fe(t,e,n,r,o){if(ve(e))return t.result.push(e),{result:t.result,inString:!0,delimiter:e,skip:0};if(e==="/"&&n==="/"){let a=Ie(r,o,`
|
|
4
|
+
`);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=Re(r,o);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}return t.result.push(e),t}function Me(t){let e=t.split("");return e.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=e[o+1];return n.inString?Ce(n,r,i):Fe(n,r,i,e,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function Le(t){let e=Me(t);return e=e.replace(Lt.TRAILING_COMMA,"$1"),e=e.replace(Lt.UNQUOTED_KEY,'"$2":'),e=e.replace(/'/g,'"'),e}function Ur(t){let e=Le(t);return JSON.parse(e)}var Pe=x(()=>{V()});var Jr,zr,Qr,Hr=(t)=>Jr.includes(t),Kr=(t)=>zr.includes(t),Xr=(t)=>Qr.includes(t),Q=(t)=>{if(Hr(t))return!0;if(Kr(t))return!1;return},H=(t)=>{if(Xr(t))return null;return},lt=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};var pt=x(()=>{Jr=["true","yes","on"],zr=["false","no","off"],Qr=["null","~",""]});var Be={};O(Be,{parseYAMLValue:()=>K,parseYAML:()=>ts,findPreviousKey:()=>_e});function qr(t){if(t.startsWith("!!")){let e=t.indexOf(" ");if(e>0)return{tag:t.substring(2,e),content:t.substring(e+1)}}return{tag:null,content:t}}function K(t){let{tag:e,content:n}=qr(t);if(e==="str")return n;let r=n.startsWith('"')&&n.endsWith('"'),o=n.startsWith("'")&&n.endsWith("'");if(r||o)return n.slice(1,-1);let i=Q(n);if(i!==void 0)return i;let c=H(n);if(c!==void 0)return c;if(Ft.INTEGER.test(n))return parseInt(n,10);if(Ft.FLOAT.test(n))return parseFloat(n);if(n.startsWith("[")&&n.endsWith("]"))return n.slice(1,-1).split(",").map((d)=>K(d.trim()));if(n.startsWith("{")&&n.endsWith("}")){let d={};return n.slice(1,-1).split(",").forEach((N)=>{let[T,y]=N.split(":").map((b)=>b.trim());if(T&&y)d[T]=K(y)}),d}return n}function _e(t,e){return Array.from({length:e},(r,o)=>e-1-o).reduce((r,o)=>{if(r!==null)return r;let s=t[o],i=s.indexOf("#");if(i>=0){let l=s.substring(0,i);if((l.match(/["']/g)||[]).length%2===0)s=l}let a=s.trim();if(a&&!a.startsWith("-")&&a.includes(":")){let l=a.indexOf(":"),p=a.substring(0,l).trim(),d=a.substring(l+1).trim();if(!d||d==="|"||d===">"||d==="|+"||d===">-")return p}return null},null)}function kt(t){let e=t.indexOf("#");if(e<0)return t;let n=t.substring(0,e);return(n.match(/["']/g)||[]).length%2===0?n:t}function Yr(t){let e=t.indexOf(":");if(e<=0)return!1;let n=t.substring(0,e);return!n.includes(" ")||n.startsWith('"')||n.startsWith("'")}function Pt(t){return t.length-t.trimStart().length}function Zr(t,e,n,r){let o=[],s=e;while(s<t.length){let c=t[s];if(!c.trim()){o.push(""),s++;continue}if(Pt(c)<=n)break;o.push(c.substring(n+2)),s++}while(o.length>0&&o[o.length-1]==="")o.pop();return{value:r==="|"?o.join(`
|
|
5
5
|
`):o.join(" ").replace(/\s+/g," ").trim(),endIdx:s-1}}function _t(t,e){if(typeof t==="string"&&t.startsWith("*")){let n=t.substring(1);return e[n]!==void 0?e[n]:t}if(Array.isArray(t))return t.map((n)=>_t(n,e));if(typeof t==="object"&&t!==null){let n={};for(let[r,o]of Object.entries(t))if(r==="<<"&&typeof o==="string"&&o.startsWith("*")){let s=o.substring(1),i=e[s];if(typeof i==="object"&&i!==null&&!Array.isArray(i))Object.assign(n,i)}else n[r]=_t(o,e);return n}return t}function ts(t){let e=t.trim().split(`
|
|
6
|
-
`),n={},s=e.find((u)=>{let l=kt(u).trim();return l&&l!=="---"&&l!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:s,indent:-1}];function c(){return i[i.length-1]}function a(u){while(i.length>1&&u(c()))i.pop()}for(let u=0;u<e.length;u++){let l=e[u],p=kt(l),d=p.trim();if(!d||d==="---"||d==="...")continue;let h=Pt(p);if(d.startsWith("- ")||d==="-"){let y=d==="-"?"":d.substring(2).trim();a((w)=>w.indent>h||w.indent>=h&&!Array.isArray(w.container));let g,b=c();if(Array.isArray(b.container)&&(b.indent===h||b.indent===-1&&h===0)){if(g=b.container,b.indent===-1)b.indent=h}else{if(g=[],b.pendingKey)b.container[b.pendingKey]=g,b.pendingKey=void 0;else if(!Array.isArray(b.container)){let w=_e(e,u);if(w)b.container[w]=g}i.push({container:g,indent:h})}if(Yr(y)){let w=y.indexOf(":"),S=y.substring(0,w).trim(),F=y.substring(w+1).trim(),_=null;if(S.includes(" &")){let z=S.split(" &");S=z[0],_=z[1]}let D={[S]:F?K(F):null};if(g.push(D),_)n[_]=D;i.push({container:D,indent:h+2})}else if(y)g.push(K(y));else{let w={};g.push(w),i.push({container:w,indent:h+2})}continue}let T=d.indexOf(":");if(T>0){let y=d.substring(0,T).trim(),g=d.substring(T+1).trim(),b=null;if(g.startsWith("&")){let S=g.indexOf(" ");if(S>0)b=g.substring(1,S),g=g.substring(S+1);else b=g.substring(1),g=""}a((S)=>S.indent>h||S.indent===h&&Array.isArray(S.container));let
|
|
7
|
-
`),n={},r=n,o=[];return e.forEach((s)=>{let i=s,c=i.indexOf("#");if(c>=0){let d=i.substring(0,c);if((d.match(/["']/g)||[]).length%2===0)i=d}let a=i.trim();if(!a)return;if(a.startsWith("[")&&a.endsWith("]")){let d=a.slice(1,-1).split(".");r=n,o=[],d.forEach((h)=>{if(!r[h])r[h]={};r=r[h],o.push(h)});return}let l=a.indexOf("=");if(l>0){let d=a.substring(0,l).trim(),h=a.substring(l+1).trim();r[d]=dt(h)}}),n}var Ve=x(()=>{V()});var Ge={};O(Ge,{parseXMLValue:()=>tt,parseXMLElement:()=>Bt,parseXMLChildren:()=>$e,parseXMLAttributes:()=>ht,parseXML:()=>ss});function tt(t){let e=t.trim();if(e==="true")return!0;if(e==="false")return!1;if(M.NUMBER.test(e))return parseFloat(e);return e}function ht(t){return Array.from(t.matchAll(M.ATTRIBUTES)).reduce((n,r)=>{let[,o,s]=r;return n[o]=tt(s),n},{})}function Bt(t){let e=t.trim(),n=e.match(M.SELF_CLOSING);if(n){let[,p,d]=n;if(d.trim().length>0)return{[p]:{_attributes:ht(d)}};return{[p]:null}}let r=e.match(M.OPEN_TAG);if(!r)return tt(e);let[,o,s,i]=r,c=i.trim();if(!M.NESTED_TAGS.test(c)){if(s.trim().length>0)return{[o]:{_attributes:ht(s),_text:tt(c)}};return{[o]:tt(c)}}let u=$e(c);if(s.trim().length>0)return{[o]:{_attributes:ht(s),...u}};return{[o]:u}}function ns(t){let e=t.split(""),n=e.reduce((s,i,c)=>{if(s.skip>0)return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:s.skip-1};if(i==="<"){let N=e[c+1]==="/",y=t.slice(c).match(/^<[^>]+\/>/);if(N)return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth-1,skip:0};if(y){let g=y[0];if(g.split("").forEach((
|
|
6
|
+
`),n={},s=e.find((u)=>{let l=kt(u).trim();return l&&l!=="---"&&l!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:s,indent:-1}];function c(){return i[i.length-1]}function a(u){while(i.length>1&&u(c()))i.pop()}for(let u=0;u<e.length;u++){let l=e[u],p=kt(l),d=p.trim();if(!d||d==="---"||d==="...")continue;let h=Pt(p);if(d.startsWith("- ")||d==="-"){let y=d==="-"?"":d.substring(2).trim();a((w)=>w.indent>h||w.indent>=h&&!Array.isArray(w.container));let g,b=c();if(Array.isArray(b.container)&&(b.indent===h||b.indent===-1&&h===0)){if(g=b.container,b.indent===-1)b.indent=h}else{if(g=[],b.pendingKey)b.container[b.pendingKey]=g,b.pendingKey=void 0;else if(!Array.isArray(b.container)){let w=_e(e,u);if(w)b.container[w]=g}i.push({container:g,indent:h})}if(Yr(y)){let w=y.indexOf(":"),S=y.substring(0,w).trim(),F=y.substring(w+1).trim(),_=null;if(S.includes(" &")){let z=S.split(" &");S=z[0],_=z[1]}let D={[S]:F?K(F):null};if(g.push(D),_)n[_]=D;i.push({container:D,indent:h+2})}else if(y)g.push(K(y));else{let w={};g.push(w),i.push({container:w,indent:h+2})}continue}let T=d.indexOf(":");if(T>0){let y=d.substring(0,T).trim(),g=d.substring(T+1).trim(),b=null;if(g.startsWith("&")){let S=g.indexOf(" ");if(S>0)b=g.substring(1,S),g=g.substring(S+1);else b=g.substring(1),g=""}a((S)=>S.indent>h||S.indent===h&&Array.isArray(S.container));let C=c(),w=C.container;if(Array.isArray(w))continue;if(g==="|"||g===">"||g==="|+"||g===">-"||g==="|-"||g===">+"){let S=g.startsWith("|")?"|":">",{value:F,endIdx:_}=Zr(e,u+1,h,S);if(w[y]=F,b)n[b]=F;u=_}else if(g){let S=K(g);if(w[y]=S,b)n[b]=S}else{let S=u+1,F=S<e.length,_=F?kt(e[S]):"",D=_.trim(),z=F?Pt(_):-1,gr=D.startsWith("- ")||D==="-",xr=F&&z>h&&D;if(gr&&z>h){if(C.pendingKey=y,b){let Z={};n[b]=Z}}else if(xr){let Z={};if(w[y]=Z,b)n[b]=Z;i.push({container:Z,indent:z})}else if(w[y]=null,b)n[b]=null}}}return _t(s,n)}var je=x(()=>{V();pt()});var De={};O(De,{parseTOMLValue:()=>dt,parseTOML:()=>es});function dt(t){if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/\\"/g,'"');if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(Mt.INTEGER.test(t))return parseInt(t,10);if(Mt.FLOAT.test(t))return parseFloat(t);if(t.startsWith("[")&&t.endsWith("]"))return t.slice(1,-1).split(",").map((a)=>dt(a.trim()));if(t.startsWith("{")&&t.endsWith("}")){let c={};return t.slice(1,-1).split(",").forEach((u)=>{let[l,p]=u.split("=").map((d)=>d.trim());if(l&&p)c[l]=dt(p)}),c}return t}function es(t){let e=t.trim().split(`
|
|
7
|
+
`),n={},r=n,o=[];return e.forEach((s)=>{let i=s,c=i.indexOf("#");if(c>=0){let d=i.substring(0,c);if((d.match(/["']/g)||[]).length%2===0)i=d}let a=i.trim();if(!a)return;if(a.startsWith("[")&&a.endsWith("]")){let d=a.slice(1,-1).split(".");r=n,o=[],d.forEach((h)=>{if(!r[h])r[h]={};r=r[h],o.push(h)});return}let l=a.indexOf("=");if(l>0){let d=a.substring(0,l).trim(),h=a.substring(l+1).trim();r[d]=dt(h)}}),n}var Ve=x(()=>{V()});var Ge={};O(Ge,{parseXMLValue:()=>tt,parseXMLElement:()=>Bt,parseXMLChildren:()=>$e,parseXMLAttributes:()=>ht,parseXML:()=>ss});function tt(t){let e=t.trim();if(e==="true")return!0;if(e==="false")return!1;if(M.NUMBER.test(e))return parseFloat(e);return e}function ht(t){return Array.from(t.matchAll(M.ATTRIBUTES)).reduce((n,r)=>{let[,o,s]=r;return n[o]=tt(s),n},{})}function Bt(t){let e=t.trim(),n=e.match(M.SELF_CLOSING);if(n){let[,p,d]=n;if(d.trim().length>0)return{[p]:{_attributes:ht(d)}};return{[p]:null}}let r=e.match(M.OPEN_TAG);if(!r)return tt(e);let[,o,s,i]=r,c=i.trim();if(!M.NESTED_TAGS.test(c)){if(s.trim().length>0)return{[o]:{_attributes:ht(s),_text:tt(c)}};return{[o]:tt(c)}}let u=$e(c);if(s.trim().length>0)return{[o]:{_attributes:ht(s),...u}};return{[o]:u}}function ns(t){let e=t.split(""),n=e.reduce((s,i,c)=>{if(s.skip>0)return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:s.skip-1};if(i==="<"){let N=e[c+1]==="/",y=t.slice(c).match(/^<[^>]+\/>/);if(N)return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth-1,skip:0};if(y){let g=y[0];if(g.split("").forEach((C)=>s.buffer.push(C)),s.depth===0){let C=s.buffer.join("").trim();s.elements.push(C),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:g.length-1}}return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth+1,skip:0}}s.buffer.push(i);let l=s.depth===0,p=s.buffer.join("").trim(),d=p.length>0,h=!i.match(/\s/);if(l&&d&&h){if(p.match(M.COMPLETE_TAGS))s.elements.push(p),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:0}},{elements:[],buffer:[],depth:0,skip:0}),r=n.buffer.join("").trim();return r.length>0?[...n.elements,r]:n.elements}function rs(t,e,n){let r=t[e];if(r===void 0){t[e]=n;return}if(Array.isArray(r)){r.push(n);return}t[e]=[r,n]}function $e(t){return ns(t).reduce((n,r)=>{let o=Bt(r);if(typeof o==="object"&&o!==null)Object.entries(o).forEach(([i,c])=>{rs(n,i,c)});return n},{})}function ss(t){let e=t.trim(),n=e.match(M.XML_DECLARATION),r=n?e.slice(n[0].length):e;return Bt(r)}var We=x(()=>{V()});var ze={};O(ze,{stripINIComments:()=>Ue,processINILine:()=>Je,parseINIValue:()=>jt,parseINI:()=>os});function jt(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(Oe.NUMBER.test(e))return parseFloat(e);return e}function Ue(t){let e=t.indexOf(";"),n=t.indexOf("#");if(!(e>=0||n>=0))return t;let o=e>=0&&n>=0?Math.min(e,n):Math.max(e,n);return t.substring(0,o)}function Je(t,e){let r=Ue(e).trim();if(!r)return t;if(r.startsWith("[")&&r.endsWith("]")){let a=r.slice(1,-1).trim();if(!t.result[a])t.result[a]={};return{result:t.result,currentSection:a}}let i=r.indexOf("=");if(i>0){let a=r.substring(0,i).trim(),u=r.substring(i+1).trim();if(t.currentSection.length>0){let p=t.result[t.currentSection];p[a]=jt(u)}else t.result[a]=jt(u)}return t}function os(t){return t.trim().split(`
|
|
8
8
|
`).reduce((r,o)=>Je(r,o),{result:{},currentSection:""}).result}var Qe=x(()=>{V()});var Vt={};O(Vt,{parseTSV:()=>is,parseCSVValue:()=>He,parseCSVLine:()=>Dt,parseCSV:()=>Ke});function Dt(t,e){let n=[],r="",o=!1,s=t.split("");return s.forEach((i,c)=>{let a=s[c+1];if(i==='"'){if(o&&a==='"'){r+='"',s.splice(c+1,1);return}o=!o;return}if(i===e&&!o){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function He(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/""/g,'"');let r=lt(e);if(r!==void 0)return r;let o=e.toLowerCase(),s=Q(o);if(s!==void 0)return s;let i=H(o);if(i!==void 0)return i;return e}function Ke(t,e=","){let n=t.trim().split(`
|
|
9
9
|
`);if(n.length===0)return[];let r=Dt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((o,s)=>{let i=Dt(s,e);if(i.length===0)return o;let c=Object.fromEntries(r.map((a,u)=>[a,He(i[u]||"")]));return[...o,c]},[])}function is(t){return Ke(t,"\t")}var $t=x(()=>{pt()});var Xe={};O(Xe,{parseProtobufJSON:()=>as,parseProtobuf:()=>cs});function cs(t){throw Error("Protobuf parsing requires a .proto schema file. Please convert your protobuf to JSON first using protoc: protoc --decode_raw < file.pb | 1ls")}function as(t){return JSON.parse(t)}var nn={};O(nn,{stripJSComments:()=>mt,parseJavaScript:()=>us,isQuoteChar:()=>qe,handleStringChar:()=>tn,handleNormalChar:()=>en,findMultiLineCommentEnd:()=>Ze,findCommentEnd:()=>Ye});function qe(t){return t==='"'||t==="'"||t==="`"}function Ye(t,e,n){let o=t.slice(e).findIndex((i)=>i===n);return o===-1?t.length-e:o}function Ze(t,e){let n=2,r=t.length-e;while(n<r){let o=t[e+n],s=t[e+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function tn(t,e,n){if(t.result.push(e),e==="\\"&&n)return t.result.push(n),{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:1};if(e===t.delimiter)return{result:t.result,inString:!1,delimiter:"",skip:0};return t}function en(t,e,n,r,o){if(qe(e))return t.result.push(e),{result:t.result,inString:!0,delimiter:e,skip:0};if(e==="/"&&n==="/"){let a=Ye(r,o,`
|
|
10
|
-
`);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=Ze(r,o);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}return t.result.push(e),t}function mt(t){let e=t.split("");return e.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=e[o+1];return n.inString?tn(n,r,i):en(n,r,i,e,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function us(
|
|
11
|
-
(${
|
|
10
|
+
`);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}if(e==="/"&&n==="*"){let a=Ze(r,o);return{result:t.result,inString:t.inString,delimiter:t.delimiter,skip:a}}return t.result.push(e),t}function mt(t){let e=t.split("");return e.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=e[o+1];return n.inString?tn(n,r,i):en(n,r,i,e,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function us(t){let e=mt(t),n=e.match(/export\s+default\s+([\s\S]+)/),o=(n?n[1]:e).trim().replace(/;$/,"");return Function(`return (${o})`)()}var rn={};O(rn,{parseTypeScript:()=>ps});function ls(){if(ft!==null)return ft;return ft=new Bun.Transpiler({loader:"ts"}),ft}function ps(t){let e=mt(t),r=ls().transformSync(e),o=r.match(/export\s+default\s+(.+?)(?:;|\n|$)/),s=o?o[1]:null;if(s===null)return null;let c=r.indexOf("export default"),u=`${r.substring(0,c)}
|
|
11
|
+
return (${s})`;return Function(u)()}var ft=null;var sn=()=>{};var cn={};O(cn,{parseENVValue:()=>on,parseENV:()=>ms});function on(t){let e=t.trim(),n=e.startsWith('"')&&e.endsWith('"'),r=e.startsWith("'")&&e.endsWith("'");if(n||r)return e.slice(1,-1);let s=Q(e);if(s!==void 0)return s;let i=H(e);if(i!==void 0)return i;let c=lt(e);if(c!==void 0)return c;return e}function ds(t){let e=t.indexOf("#");if(!(e>=0))return t;let r=t.substring(0,e);if(r.match(/["'].*["']/)!==null){if((r.match(/["']/g)||[]).length%2!==0)return t}return r}function hs(t,e){let r=ds(e).trim();if(!r)return t;let i=r.startsWith("export ")?r.substring(7).trim():r,c=i.indexOf("=");if(c>0){let u=i.substring(0,c).trim(),l=i.substring(c+1).trim();t.result[u]=on(l)}return t}function ms(t){return t.trim().split(`
|
|
12
12
|
`).reduce((r,o)=>hs(r,o),{result:{}}).result}var an=x(()=>{pt()});var un={};O(un,{parseNDJSON:()=>fs});function fs(t){return t.trim().split(`
|
|
13
13
|
`).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}function gs(t){return t.trim().split(`
|
|
14
14
|
`).filter((e)=>e.length>0)}async function gt(t,e){switch(e??Gt(t)){case"json":return JSON.parse(t);case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (Pe(),ke));return r(t)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (je(),Be));return r(t)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (Ve(),De));return r(t)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (We(),Ge));return r(t)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (Qe(),ze));return r(t)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => ($t(),Vt));return r(t)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => ($t(),Vt));return r(t)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => Xe);return r(t)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => nn);return r(t)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (sn(),rn));return r(t)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (an(),cn));return r(t)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => un);return r(t)}case"lines":return gs(t);case"text":default:return t}}function bs(t){let e=t.split(`
|
|
15
15
|
`),n=E.NDJSON_FEATURES.test(t),r=e.every(xs);if(n&&r)return"ndjson";let s=e[0],i=ln(s,/,/g),c=ln(s,/\t/g);if(c>0&&c>=i)return"tsv";if(i>0)return"csv";return"lines"}function ys(t){if(E.ENV_FEATURES.test(t))return"env";if(E.TOML_QUOTED_VALUES.test(t))return"toml";let r=E.SECTION_HEADER.test(t),o=E.TOML_SECTION.test(t),s=E.TOML_SYNTAX.test(t);if(r&&o&&s)return"toml";let c=E.INI_SYNTAX.test(t);if(r&&c)return"ini";if(c)return"ini";return"text"}function Gt(t){let e=t.trim();if(!e)return"text";let n=e[0],r=e[e.length-1],o=Ns(e,n,r);if(o)return o;let s=Os(e);if(s)return s;return"text"}var xs=(t)=>{let e=t.trim();if(!e)return!0;try{return JSON.parse(e),!0}catch{return!1}},ln=(t,e)=>(t.match(e)||[]).length,Ss=(t)=>{try{return JSON.parse(t),"json"}catch{return E.JSON5_FEATURES.test(t)?"json5":null}},ws=(t,e,n)=>{if(e==="{"&&n==="}"||e==="["&&n==="]")return Ss(t);return null},Es=(t)=>{let e=t.startsWith("<?xml"),n=/<\/\w+>/.test(t);return e||n?"xml":null},As=(t)=>E.TS_INTERFACE.test(t)||E.TS_TYPE_ALIAS.test(t)||E.TS_TYPE_ANNOTATION.test(t),Ts=(t)=>{if(!E.JS_EXPORT.test(t))return null;return As(t)?"typescript":"javascript"},Ns=(t,e,n)=>{switch(e){case"{":case"[":return ws(t,e,n);case"<":return Es(t);case"-":return t.startsWith("---")?"yaml":null;case"e":return Ts(t);case"i":return E.TS_INTERFACE.test(t)?"typescript":null;case"t":return E.TS_TYPE_ALIAS.test(t)?"typescript":null;case"c":case"l":case"v":return E.TS_TYPE_ANNOTATION.test(t)?"typescript":null;default:return null}},Os=(t)=>{if(t.includes("="))return ys(t);let n=t.includes(": "),r=/^[\s]*-\s+/m.test(t);if(n||r)return"yaml";if(t.includes(`
|
|
16
|
-
`))return bs(t);return null};var xt=x(()=>{V()});async function pn(t){let e=[];for await(let r of process.stdin)e.push(r);let n=Buffer.concat(e).toString("utf-8").trim();if(!n)return null;return gt(n,t)}var Wt=x(()=>{xt()});var vs,Is,
|
|
16
|
+
`))return bs(t);return null};var xt=x(()=>{V()});async function pn(t){let e=[];for await(let r of process.stdin)e.push(r);let n=Buffer.concat(e).toString("utf-8").trim();if(!n)return null;return gt(n,t)}var Wt=x(()=>{xt()});var vs,Is,Rs,dn,hn;var bt=x(()=>{vs=[".ts",".js",".tsx",".jsx"],Is=[".json",".yml",".yaml"],Rs=[".md",".txt"],dn=[...vs,...Is,...Rs],hn=/[.*+?^${}()|[\]\\]/g});import{readdir as Cs,stat as mn}from"fs/promises";import{join as Fs,extname as Ms,basename as Ls}from"path";async function yt(t,e=!0){let r=await Bun.file(t).text();if(!e)return r;return gt(r)}function ks(t,e){return{path:t,name:Ls(t),ext:Ms(t),size:Number(e.size),isDirectory:e.isDirectory(),isFile:e.isFile(),modified:e.mtime,created:e.birthtime}}async function Ps(t){let e=await mn(t);return ks(t,e)}function _s(t){return t.startsWith(".")}function Bs(t,e){return e||!_s(t)}function js(t,e){if(e===void 0)return!0;return e.includes(t)}function Ds(t,e){if(e===void 0)return!0;return e.test(t)}function Vs(t,e,n){let r=js(t.ext,e),o=Ds(t.name,n);return r&&o}function $s(t,e){return t<=(e??1/0)}async function Gs(t,e,n,r){if(!Bs(e,r.includeHidden??!1))return[];let s=Fs(t,e),i=await Ps(s);if(i.isFile)return Vs(i,r.extensions,r.pattern)?[i]:[];if(!i.isDirectory)return[];let a=r.recursive===!0?await fn(s,n+1,r):[];return[i,...a]}async function fn(t,e,n){if(!$s(e,n.maxDepth))return[];let o=await Cs(t);return(await Promise.all(o.map((i)=>Gs(t,i,e,n)))).flat()}async function Ut(t,e={}){return fn(t,0,e)}function Ws(t,e){if(typeof t!=="string")return t;return new RegExp(t,e?"gi":"g")}function Us(t,e,n,r,o,s){let i={file:t,line:e+1,column:n+1,match:r};if(s===void 0)return i;let a=Math.max(0,e-s),u=Math.min(o.length,e+s+1);return{...i,context:o.slice(a,u)}}function Js(t,e,n){if(!n)return;let r=e instanceof Error?e.message:String(e);console.error(`Failed to search ${t}: ${r}`)}function zs(t,e,n,r,o,s){return[...t.matchAll(n)].map((c)=>Us(r,e,c.index,t,o,s))}async function gn(t,e,n){try{let r=await yt(t,!1);if(typeof r!=="string")return[];let s=r.split(`
|
|
17
17
|
`),i=s.flatMap((a,u)=>zs(a,u,e,t,s,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return Js(t,r,n.verbose??!1),[]}}async function Qs(t,e,n){let r=await Ut(t,{recursive:!0,extensions:[...dn]});return(await Promise.all(r.filter((s)=>s.isFile).map((s)=>gn(s.path,e,n)))).flat()}async function xn(t,e,n={}){let r=Ws(t,n.ignoreCase??!1),o=await mn(e);if(o.isFile())return gn(e,r,n);if(o.isDirectory()&&n.recursive)return Qs(e,r,n);return[]}var Jt=x(()=>{bt();xt()});var St=()=>{};var yn,Sn="+-*/%<>!&|=",wn;var En=x(()=>{St();yn={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},wn=[" ","\t",`
|
|
18
|
-
`,"\r"]});function $(t,e,n){return{type:t,value:e,position:n}}class et{input;position=0;current;constructor(t){this.input=t,this.current=this.input[0]||""}tokenize(){let t=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let e=this.nextToken();if(e)t.push(e)}return t.push($("EOF","",this.position)),t}nextToken(){let t=this.position,e=yn[this.current];if(e){let u=this.current;return this.advance(),$(e,u,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),$("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let o=this.isDigit(this.current),s=this.current==="-"&&this.isDigit(this.peek());if(o||s)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let t=this.position,e=this.current,n=[];this.advance();while(this.current!==e&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===e)this.advance();return $("STRING",n.join(""),t)}readNumber(){let t=this.position,e="";if(this.current==="-")e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance()}return $("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return $("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return $("OPERATOR",e,t)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(t){return wn.includes(t)}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){let e=t>="a"&&t<="z",n=t>="A"&&t<="Z";return e||n||t==="_"||t==="$"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}isOperator(t){return Sn.includes(t)}}var zt=x(()=>{St();En()});var An=()=>{};var C=(t)=>{return{type:"Literal",value:t}},Qt=(t)=>{if(t==="true")return C(!0);if(t==="false")return C(!1);if(t==="null")return C(null);return};var Tn=x(()=>{An()});function k(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function G(t,e){return{type:"PropertyAccess",property:t,object:e}}function Hs(t,e){return{type:"IndexAccess",index:t,object:e}}function Ks(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function Nn(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function Xs(t,e){return{type:"ObjectOperation",operation:t,object:e}}function qs(t){return{type:"ArraySpread",object:t}}function Ys(t,e){return{type:"ArrowFunction",params:t,body:e}}function wt(t){return{type:"Root",expression:t}}function Zs(t){return On.includes(t)}class nt{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return wt();let e=this.parseExpression();return wt(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT")return this.advance(),this.parseAccessChain();if(t==="LEFT_BRACKET")return this.parseArrayAccess();if(t==="IDENTIFIER")return this.parseIdentifierOrFunction();if(t==="STRING"){let e=this.current.value;return this.advance(),C(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),C(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(k(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),qs(t);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),G(c,t)}let r=this.current.type==="NUMBER",o=this.current.type==="OPERATOR"&&this.current.value==="-",s=this.current.type==="COLON";if(r||o||s)return this.parseNumericIndexOrSlice(t);throw Error(k(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(t){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,t);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,t);return this.expect("RIGHT_BRACKET"),Hs(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",o=n||r,s=o?this.parseNumber():void 0;if(o)this.advance();return this.expect("RIGHT_BRACKET"),Ks(t,s,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(k(this.current,"Expected operation name after {"));let n=this.current.value;if(!Zs(n)){let r=On.join(", ");throw Error(k(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Xs(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=Qt(t);if(n)return n;return G(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return Ys(t,e)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),e}return this.parseBinaryExpression()}parseBinaryExpression(){let t=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let e=this.current.value;this.advance();let n=this.parseFunctionTerm();t=Nn(`__operator_${e}__`,[n],t)}return t}parseFunctionTerm(){let t=this.current.type;if(t==="IDENTIFIER")return this.parseIdentifierChain();if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),C(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),C(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(k(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=Qt(t);if(e)return e;let n=G(t),r=()=>this.current.type==="DOT",o=()=>this.current.type==="IDENTIFIER",s=()=>this.current.type==="LEFT_PAREN";while(r()||s()){if(s()){let c=n,a=c.property,u=c.object;n=this.parseMethodCall(u?u:wt(),a);continue}if(this.advance(),!o())break;let i=this.current.value;this.advance(),n=G(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),Nn(e,n,t)}parseMethodArguments(){let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let e=this.parseMethodArgument();if(t.push(e),this.current.type==="COMMA")this.advance()}return t}parseMethodArgument(){let t=this.current.type;if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}if(t==="IDENTIFIER"){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);return G(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),C(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),C(e)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")t.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),t}parsePostfix(t){let e=t;while(!0){let n=this.current.type;if(n==="DOT"){e=this.parsePostfixDot(e);continue}if(n==="LEFT_BRACKET"){e=this.parseBracketAccess(e);continue}if(n==="LEFT_PAREN"){if(e.type==="PropertyAccess"&&!e.object){let s=e.property;e=this.parseMethodCall(wt(),s);continue}}break}return e}parsePostfixDot(t){this.advance();let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(t,n);return G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(k(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return t?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(t){if(this.current.type!==t)throw Error(k(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var On;var Ht=x(()=>{St();Tn();On=["keys","values","entries","length"]});function vn(t){return t.startsWith("__operator_")&&t.endsWith("__")}function In(t){return t.slice(11,-2)}function Cn(t,e,n){let r=to[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function eo(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function Kt(t){return Object.values(t)[0]}function Fn(t){return t!==null&&typeof t==="object"}function Xt(t,e){if(!Fn(t))return;return t[e]}function qt(t,e){return t<0?e+t:t}function no(t,e){if(!Array.isArray(t))return;let n=qt(e,t.length);return t[n]}function ro(t,e,n){if(!Array.isArray(t))return;let r=t.length,o=e!==void 0?qt(e,r):0,s=n!==void 0?qt(n,r):r;return t.slice(o,s)}function so(t,e){if(!Fn(t))return;switch(e){case"keys":return Object.keys(t);case"values":return Object.values(t);case"entries":return Object.entries(t);case"length":return Array.isArray(t)?t.length:Object.keys(t).length}}function Rn(t,e,n){if(!oo(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(o){let s=io(o);throw Error(`Error executing method ${e}: ${s}`)}}class rt{evaluate(t,e){switch(t.type){case"Root":return t.expression?this.evaluate(t.expression,e):e;case"PropertyAccess":return this.evaluatePropertyAccess(t,e);case"IndexAccess":return no(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return ro(t.object?this.evaluate(t.object,e):e,t.start,t.end);case"ArraySpread":return t.object?this.evaluate(t.object,e):e;case"MethodCall":return this.evaluateMethodCall(t,e);case"ObjectOperation":return so(t.object?this.evaluate(t.object,e):e,t.operation);case"Literal":return t.value;case"ArrowFunction":return this.createFunction(t);default:throw Error(`Unknown AST node type: ${t.type}`)}}evaluatePropertyAccess(t,e){let n=t.object?this.evaluate(t.object,e):e;return Xt(n,t.property)}evaluateArg(t,e){return t.type==="ArrowFunction"?this.createFunction(t):this.evaluate(t,e)}evaluateMethodCall(t,e){let n=t.object?this.evaluate(t.object,e):e;if(vn(t.method)){let s=In(t.method),i=this.evaluate(t.args[0],e);return Cn(n,s,i)}let o=t.args.map((s)=>this.evaluateArg(s,e));return Rn(n,t.method,o)}createFunction(t){return(...e)=>{let n=eo(t.params,e);return this.evaluateFunctionBody(t.body,n)}}evaluateFunctionBody(t,e){switch(t.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(t,e);case"MethodCall":return this.evaluateMethodCallInFunction(t,e);case"Literal":return t.value;case"Root":return t.expression?this.evaluateFunctionBody(t.expression,e):e;default:return this.evaluate(t,Kt(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let s=this.evaluateFunctionBody(t.object,e);return Xt(s,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let o=Kt(e);return Xt(o,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):Kt(e);if(vn(t.method)){let s=In(t.method),i=this.evaluateFunctionBody(t.args[0],e);return Cn(n,s,i)}let o=t.args.map((s)=>this.evaluateFunctionBody(s,e));return Rn(n,t.method,o)}}var to,oo=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},io=(t)=>t instanceof Error?t.message:String(t);var Yt=x(()=>{to={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,">":(t,e)=>t>e,"<":(t,e)=>t<e,">=":(t,e)=>t>=e,"<=":(t,e)=>t<=e,"==":(t,e)=>t==e,"===":(t,e)=>t===e,"!=":(t,e)=>t!=e,"!==":(t,e)=>t!==e,"&&":(t,e)=>t&&e,"||":(t,e)=>t||e}});var W;var te=x(()=>{W={ERROR:0,WARN:1,INFO:2,DEBUG:3}});var ao,yc;var kn=x(()=>{te();ao={ERROR:W.ERROR,WARN:W.WARN,INFO:W.INFO,DEBUG:W.DEBUG},yc=process.env.LOG_LEVEL?ao[process.env.LOG_LEVEL]||W.INFO:W.INFO});function ee(t){return t.replace(hn,"\\$&")}var Pn=x(()=>{bt();bt();Jt();kn();Et();Wt();te()});function ot(t){return uo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function _n(t){return lo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Bn(){let t=B.filter((s)=>s.type==="array"),e=B.filter((s)=>s.type==="object"),n=B.filter((s)=>s.type==="string"),r=B.filter((s)=>s.type==="any"),o=(s,i)=>{let c=Math.max(...i.map((p)=>p.short.length)),a=Math.max(...i.map((p)=>p.full.length)),u=`
|
|
18
|
+
`,"\r"]});function $(t,e,n){return{type:t,value:e,position:n}}class et{input;position=0;current;constructor(t){this.input=t,this.current=this.input[0]||""}tokenize(){let t=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let e=this.nextToken();if(e)t.push(e)}return t.push($("EOF","",this.position)),t}nextToken(){let t=this.position,e=yn[this.current];if(e){let u=this.current;return this.advance(),$(e,u,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),$("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let o=this.isDigit(this.current),s=this.current==="-"&&this.isDigit(this.peek());if(o||s)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let t=this.position,e=this.current,n=[];this.advance();while(this.current!==e&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===e)this.advance();return $("STRING",n.join(""),t)}readNumber(){let t=this.position,e="";if(this.current==="-")e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance()}return $("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return $("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return $("OPERATOR",e,t)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(t){return wn.includes(t)}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){let e=t>="a"&&t<="z",n=t>="A"&&t<="Z";return e||n||t==="_"||t==="$"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}isOperator(t){return Sn.includes(t)}}var zt=x(()=>{St();En()});var An=()=>{};var R=(t)=>{return{type:"Literal",value:t}},Qt=(t)=>{if(t==="true")return R(!0);if(t==="false")return R(!1);if(t==="null")return R(null);return};var Tn=x(()=>{An()});function k(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function G(t,e){return{type:"PropertyAccess",property:t,object:e}}function Hs(t,e){return{type:"IndexAccess",index:t,object:e}}function Ks(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function Nn(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function Xs(t,e){return{type:"ObjectOperation",operation:t,object:e}}function qs(t){return{type:"ArraySpread",object:t}}function Ys(t,e){return{type:"ArrowFunction",params:t,body:e}}function wt(t){return{type:"Root",expression:t}}function Zs(t){return On.includes(t)}class nt{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return wt();let e=this.parseExpression();return wt(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT")return this.advance(),this.parseAccessChain();if(t==="LEFT_BRACKET")return this.parseArrayAccess();if(t==="IDENTIFIER")return this.parseIdentifierOrFunction();if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(k(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),qs(t);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),G(c,t)}let r=this.current.type==="NUMBER",o=this.current.type==="OPERATOR"&&this.current.value==="-",s=this.current.type==="COLON";if(r||o||s)return this.parseNumericIndexOrSlice(t);throw Error(k(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(t){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,t);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,t);return this.expect("RIGHT_BRACKET"),Hs(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",o=n||r,s=o?this.parseNumber():void 0;if(o)this.advance();return this.expect("RIGHT_BRACKET"),Ks(t,s,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(k(this.current,"Expected operation name after {"));let n=this.current.value;if(!Zs(n)){let r=On.join(", ");throw Error(k(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Xs(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=Qt(t);if(n)return n;return G(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return Ys(t,e)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),e}return this.parseBinaryExpression()}parseBinaryExpression(){let t=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let e=this.current.value;this.advance();let n=this.parseFunctionTerm();t=Nn(`__operator_${e}__`,[n],t)}return t}parseFunctionTerm(){let t=this.current.type;if(t==="IDENTIFIER")return this.parseIdentifierChain();if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(k(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=Qt(t);if(e)return e;let n=G(t),r=()=>this.current.type==="DOT",o=()=>this.current.type==="IDENTIFIER",s=()=>this.current.type==="LEFT_PAREN";while(r()||s()){if(s()){let c=n,a=c.property,u=c.object;n=this.parseMethodCall(u?u:wt(),a);continue}if(this.advance(),!o())break;let i=this.current.value;this.advance(),n=G(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),Nn(e,n,t)}parseMethodArguments(){let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let e=this.parseMethodArgument();if(t.push(e),this.current.type==="COMMA")this.advance()}return t}parseMethodArgument(){let t=this.current.type;if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}if(t==="IDENTIFIER"){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);return G(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),R(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),R(e)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")t.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),t}parsePostfix(t){let e=t;while(!0){let n=this.current.type;if(n==="DOT"){e=this.parsePostfixDot(e);continue}if(n==="LEFT_BRACKET"){e=this.parseBracketAccess(e);continue}if(n==="LEFT_PAREN"){if(e.type==="PropertyAccess"&&!e.object){let s=e.property;e=this.parseMethodCall(wt(),s);continue}}break}return e}parsePostfixDot(t){this.advance();let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(t,n);return G(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(k(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(k(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return t?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(t){if(this.current.type!==t)throw Error(k(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var On;var Ht=x(()=>{St();Tn();On=["keys","values","entries","length"]});function vn(t){return t.startsWith("__operator_")&&t.endsWith("__")}function In(t){return t.slice(11,-2)}function Rn(t,e,n){let r=to[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function eo(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function Kt(t){return Object.values(t)[0]}function Fn(t){return t!==null&&typeof t==="object"}function Xt(t,e){if(!Fn(t))return;return t[e]}function qt(t,e){return t<0?e+t:t}function no(t,e){if(!Array.isArray(t))return;let n=qt(e,t.length);return t[n]}function ro(t,e,n){if(!Array.isArray(t))return;let r=t.length,o=e!==void 0?qt(e,r):0,s=n!==void 0?qt(n,r):r;return t.slice(o,s)}function so(t,e){if(!Fn(t))return;switch(e){case"keys":return Object.keys(t);case"values":return Object.values(t);case"entries":return Object.entries(t);case"length":return Array.isArray(t)?t.length:Object.keys(t).length}}function Cn(t,e,n){if(!oo(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(o){let s=io(o);throw Error(`Error executing method ${e}: ${s}`)}}class rt{evaluate(t,e){switch(t.type){case"Root":return t.expression?this.evaluate(t.expression,e):e;case"PropertyAccess":return this.evaluatePropertyAccess(t,e);case"IndexAccess":return no(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return ro(t.object?this.evaluate(t.object,e):e,t.start,t.end);case"ArraySpread":return t.object?this.evaluate(t.object,e):e;case"MethodCall":return this.evaluateMethodCall(t,e);case"ObjectOperation":return so(t.object?this.evaluate(t.object,e):e,t.operation);case"Literal":return t.value;case"ArrowFunction":return this.createFunction(t);default:throw Error(`Unknown AST node type: ${t.type}`)}}evaluatePropertyAccess(t,e){let n=t.object?this.evaluate(t.object,e):e;return Xt(n,t.property)}evaluateArg(t,e){return t.type==="ArrowFunction"?this.createFunction(t):this.evaluate(t,e)}evaluateMethodCall(t,e){let n=t.object?this.evaluate(t.object,e):e;if(vn(t.method)){let s=In(t.method),i=this.evaluate(t.args[0],e);return Rn(n,s,i)}let o=t.args.map((s)=>this.evaluateArg(s,e));return Cn(n,t.method,o)}createFunction(t){return(...e)=>{let n=eo(t.params,e);return this.evaluateFunctionBody(t.body,n)}}evaluateFunctionBody(t,e){switch(t.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(t,e);case"MethodCall":return this.evaluateMethodCallInFunction(t,e);case"Literal":return t.value;case"Root":return t.expression?this.evaluateFunctionBody(t.expression,e):e;default:return this.evaluate(t,Kt(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let s=this.evaluateFunctionBody(t.object,e);return Xt(s,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let o=Kt(e);return Xt(o,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):Kt(e);if(vn(t.method)){let s=In(t.method),i=this.evaluateFunctionBody(t.args[0],e);return Rn(n,s,i)}let o=t.args.map((s)=>this.evaluateFunctionBody(s,e));return Cn(n,t.method,o)}}var to,oo=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},io=(t)=>t instanceof Error?t.message:String(t);var Yt=x(()=>{to={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,">":(t,e)=>t>e,"<":(t,e)=>t<e,">=":(t,e)=>t>=e,"<=":(t,e)=>t<=e,"==":(t,e)=>t==e,"===":(t,e)=>t===e,"!=":(t,e)=>t!=e,"!==":(t,e)=>t!==e,"&&":(t,e)=>t&&e,"||":(t,e)=>t||e}});var W;var te=x(()=>{W={ERROR:0,WARN:1,INFO:2,DEBUG:3}});var ao,yc;var kn=x(()=>{te();ao={ERROR:W.ERROR,WARN:W.WARN,INFO:W.INFO,DEBUG:W.DEBUG},yc=process.env.LOG_LEVEL?ao[process.env.LOG_LEVEL]||W.INFO:W.INFO});function ee(t){return t.replace(hn,"\\$&")}var Pn=x(()=>{bt();bt();Jt();kn();Et();Wt();te()});function ot(t){return uo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function _n(t){return lo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Bn(){let t=B.filter((s)=>s.type==="array"),e=B.filter((s)=>s.type==="object"),n=B.filter((s)=>s.type==="string"),r=B.filter((s)=>s.type==="any"),o=(s,i)=>{let c=Math.max(...i.map((p)=>p.short.length)),a=Math.max(...i.map((p)=>p.full.length)),u=`
|
|
19
19
|
${s}:
|
|
20
20
|
`,l=i.map((p)=>` ${p.short.padEnd(c+2)} \u2192 ${p.full.padEnd(a+2)} # ${p.description}`).join(`
|
|
21
21
|
`);return u+l};return`
|
|
@@ -31,7 +31,7 @@ Examples:
|
|
|
31
31
|
|
|
32
32
|
1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
|
|
33
33
|
1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
|
|
34
|
-
`}var B,
|
|
34
|
+
`}var B,Cc,Fc,uo,lo;var Et=x(()=>{Pn();B=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".fndIdx",full:".findIndex",description:"Find index of first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".psh",full:".push",description:"Add to end",type:"array"},{short:".pp",full:".pop",description:"Remove from end",type:"array"},{short:".shft",full:".shift",description:"Remove from start",type:"array"},{short:".unshft",full:".unshift",description:"Add to start",type:"array"},{short:".fltMap",full:".flatMap",description:"Map and flatten",type:"array"},{short:".flt1",full:".flat",description:"Flatten array",type:"array"},{short:".incl",full:".includes",description:"Check if includes",type:"array"},{short:".idxOf",full:".indexOf",description:"Find index",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".trmSt",full:".trimStart",description:"Remove leading whitespace",type:"string"},{short:".trmEnd",full:".trimEnd",description:"Remove trailing whitespace",type:"string"},{short:".rpl",full:".replace",description:"Replace text",type:"string"},{short:".rplAll",full:".replaceAll",description:"Replace all occurrences",type:"string"},{short:".pdSt",full:".padStart",description:"Pad start",type:"string"},{short:".pdEnd",full:".padEnd",description:"Pad end",type:"string"},{short:".stsWith",full:".startsWith",description:"Check if starts with",type:"string"},{short:".endsWith",full:".endsWith",description:"Check if ends with",type:"string"},{short:".sbstr",full:".substring",description:"Extract substring",type:"string"},{short:".chr",full:".charAt",description:"Get character at index",type:"string"},{short:".chrCd",full:".charCodeAt",description:"Get character code",type:"string"},{short:".mtch",full:".match",description:"Match pattern",type:"string"},{short:".str",full:".toString",description:"Convert to string",type:"any"},{short:".json",full:".toJSON",description:"Convert to JSON",type:"any"},{short:".val",full:".valueOf",description:"Get primitive value",type:"any"}],Cc=new Map(B.map((t)=>[t.short,t.full])),Fc=new Map(B.map((t)=>[t.full,t.short])),uo=B.map((t)=>({regex:new RegExp(`${ee(t.short)}(?![a-zA-Z])`,"g"),replacement:t.full})).sort((t,e)=>e.replacement.length-t.replacement.length),lo=B.map((t)=>({regex:new RegExp(`${ee(t.full)}(?![a-zA-Z])`,"g"),replacement:t.short})).sort((t,e)=>e.regex.source.length-t.regex.source.length)});var At=(t)=>{if(t===null)return"null";if(Array.isArray(t))return"Array";let e=typeof t;return e.charAt(0).toUpperCase()+e.slice(1)},Tt=(t,e)=>{if(e==="null")return"null";if(e==="String")return`"${t}"`;if(e==="Array")return`[${t.length} items]`;if(e==="Object")return`{${Object.keys(t).length} keys}`;return String(t)},ne=(t,e="",n=[])=>{if(t===null||t===void 0){let i=At(t),c=Tt(t,i);return n.push({path:e||".",value:t,type:i,displayValue:c}),n}if(Array.isArray(t)){let i=At(t),c=Tt(t,i),a=e||".";return n.push({path:a,value:t,type:i,displayValue:c}),t.forEach((u,l)=>{let p=e?`${e}[${l}]`:`.[${l}]`;ne(u,p,n)}),n}if(typeof t==="object"){let i=At(t),c=Tt(t,i),a=e||".";if(e)n.push({path:a,value:t,type:i,displayValue:c});return Object.entries(t).forEach(([l,p])=>{let d=/[^a-zA-Z0-9_$]/.test(l),h=e?d?`${e}["${l}"]`:`${e}.${l}`:d?`.["${l}"]`:`.${l}`;ne(p,h,n)}),n}let r=At(t),o=Tt(t,r),s=e||".";return n.push({path:s,value:t,type:r,displayValue:o}),n},Nt=(t)=>{return ne(t)};var po=(t,e,n)=>{let r=n.length*100,o=(p,d,h)=>{if(h===0)return p;let g=n[h-1]===d-1?5:0;return p+g},s=n.reduce(o,0),a=n[0]===0?10:0,u=t.length-e.length;return r+s+a-u},ho=(t,e)=>{let n=t.toLowerCase(),r=e.toLowerCase(),o=[],s=0,i=0,c=()=>{let u=s<n.length,l=i<r.length;return u&&l};while(c()){let u=n[s],l=r[i];if(u===l)o.push(s),i=i+1;s=s+1}return i===r.length?o:null},mo=(t,e,n)=>{let r=ho(e,n);if(!r)return null;let s=po(e,n,r);return Object.assign({},{item:t,score:s,matches:r})},fo=(t,e)=>e.score-t.score,P=(t,e,n)=>{if(!e){let u=(l)=>{return Object.assign({},{item:l,score:0,matches:[]})};return t.map(u)}let o=(u)=>{let l=n(u);return mo(u,l,e)},s=t.map(o),i=(u)=>u!==null;return s.filter(i).sort(fo)};var jn=(t,e)=>{let n=P(t,"",(o)=>o.path);return Object.assign({},{mode:"explore",paths:t,matches:n,query:"",selectedIndex:0,builder:null,originalData:e,methodMatches:[],propertyMatches:[]})},re=(t,e)=>{let n=P(t.paths,e,(s)=>s.path),r=n.length>0?0:t.selectedIndex;return Object.assign({},t,{query:e,matches:n,selectedIndex:r})},U=(t,e)=>{let n=t.mode==="explore",r=t.mode==="build",o=n?t.matches.length:r?t.methodMatches.length:t.propertyMatches.length;if(o===0)return t;let c=t.selectedIndex+e;if(c<0)c=o-1;else if(c>=o)c=0;return Object.assign({},t,{selectedIndex:c})},Dn=(t)=>{let e=t.matches.length>0,n=t.selectedIndex>=0&&t.selectedIndex<t.matches.length;if(e&&n)return t.matches[t.selectedIndex].item;return null};var se=()=>{};import{stdout as X}from"process";var J=()=>{X.write("\x1B[2J\x1B[H")},oe=(t,e=1)=>{X.write(`\x1B[${t};${e}H`)},Vn=()=>{X.write("\x1B[2K")},$n=()=>{X.write("\x1B[J")},Gn=()=>{X.write("\x1B[?25l")},Wn=()=>{X.write("\x1B[?25h")},Un=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},Jn=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!1);process.stdin.pause()},m,f=(t,e)=>{let n=m.reset;return e.concat(t,n)},it=(t,e)=>{let n=t.split(""),r=m.bright.concat(m.cyan),o=(c,a)=>{return e.includes(a)?f(c,r):c};return n.map(o).join("")};var Ot=x(()=>{m=Object.assign({},{reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",gray:"\x1B[90m"})});import{stdout as j}from"process";var v=10,go=(t,e)=>it(t,e),xo=(t)=>{let e=`[${t}]`;return f(e,m.dim)},bo=(t)=>f(t,m.gray),zn=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},yo=(t,e,n)=>{let r=zn(e),o=go(t.signature,n),s=t.category?xo(t.category):"",i=bo(t.description);return r.concat(" ",o).concat(s?" "+s:"").concat(" - ",i)},So=(t,e)=>{let{item:n,matches:r}=t,o=zn(e),s=it(n.path,r),i=f(`[${n.type}]`,m.dim),c=f(n.displayValue,m.gray);return o.concat(" ",s).concat(" ",i).concat(" ",c)},wo=(t)=>{if(t.builder===null)return"";let n="Expression Builder",r=m.bright.concat(m.cyan),o=f(n,r),s=t.builder.expression,i=`
|
|
35
35
|
|
|
36
36
|
Building: `,c=f(s,m.bright.concat(m.yellow)),a=`
|
|
37
37
|
|
|
@@ -49,7 +49,7 @@ Search properties for '${u.paramName}' (${u.paramType}): `,p=t.query;return s.co
|
|
|
49
49
|
|
|
50
50
|
... `.concat(String(e)," more");return f(r,m.dim)}return""},Hn=()=>{let t=`
|
|
51
51
|
|
|
52
|
-
`.concat(f("\u2191/\u2193",m.bright)," navigate ",f("\u2192/Tab",m.bright)," accept ",f("\u2190",m.bright)," undo ",f("Enter",m.bright)," execute ",f("Esc",m.bright)," quit");return f(t,m.dim)},Kn=(t)=>{J();let e=wo(t);j.write(e);let n=Ao(t);j.write(n);let r=t.methodMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)},Xn=(t)=>{J();let e=Eo(t);j.write(e);let n=To(t);j.write(n);let r=t.propertyMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)};var qn=x(()=>{Ot()});import{stdout as Zn}from"process";var q=10,vt,tr=!0,No=(t,e)=>it(t,e),Oo=(t)=>{let r="[".concat(t,"]");return f(r,m.dim)},vo=(t)=>f(t,m.gray),Io=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},
|
|
52
|
+
`.concat(f("\u2191/\u2193",m.bright)," navigate ",f("\u2192/Tab",m.bright)," accept ",f("\u2190",m.bright)," undo ",f("Enter",m.bright)," execute ",f("Esc",m.bright)," quit");return f(t,m.dim)},Kn=(t)=>{J();let e=wo(t);j.write(e);let n=Ao(t);j.write(n);let r=t.methodMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)},Xn=(t)=>{J();let e=Eo(t);j.write(e);let n=To(t);j.write(n);let r=t.propertyMatches.length,o=Qn(r);j.write(o);let s=Hn();j.write(s)};var qn=x(()=>{Ot()});import{stdout as Zn}from"process";var q=10,vt,tr=!0,No=(t,e)=>it(t,e),Oo=(t)=>{let r="[".concat(t,"]");return f(r,m.dim)},vo=(t)=>f(t,m.gray),Io=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},Ro=(t,e)=>{let{item:n,matches:r}=t,o=Io(e),s=No(n.path,r),i=Oo(n.type),c=vo(n.displayValue);return o.concat(" ",s).concat(" ",i).concat(" ",c)},Co=()=>{let e=m.bright.concat(m.cyan);return f("1ls Interactive Explorer",e)},Fo,Mo,Yn=5,Lo=(t)=>f(String(t),m.cyan),ko=(t)=>{let n=JSON.stringify(t,null,2).split(`
|
|
53
53
|
`),r=n.slice(0,Yn),o=n.length>Yn,s=f(r.join(`
|
|
54
54
|
`),m.cyan);return o?s.concat(f(`
|
|
55
55
|
... (truncated)`,m.dim)):s},Po=(t)=>{let{type:e,displayValue:n,value:r}=t;if(Fo.includes(e))return Lo(n);if(Mo.includes(e))return ko(r);return f(String(r),m.cyan)},_o=(t)=>{let{matches:e,selectedIndex:n}=t,r=e.length>0,o=n>=0&&n<e.length;if(!(r&&o))return"";let i=e[n].item,c=f(`
|
|
@@ -57,22 +57,22 @@ Search properties for '${u.paramName}' (${u.paramType}): `,p=t.query;return s.co
|
|
|
57
57
|
Preview:
|
|
58
58
|
`,m.bright),a=Po(i);return c.concat(a)},Bo=()=>{let t=`
|
|
59
59
|
|
|
60
|
-
`.concat(f("\u2191/\u2193",m.bright)," navigate ",f("Enter",m.bright)," select ",f("Tab",m.bright)," build ",f("Esc/q",m.bright)," quit");return f(t,m.dim)},jo=(t,e)=>{let n=Math.floor(q/2),r=Math.max(0,t-n),o=Math.min(e,r+q);return{start:o-r<q&&e>=q?Math.max(0,o-q):r,end:o}},Do=(t)=>{let{selectedIndex:e,matches:n}=t,r=n.length;if(r===0)return[f("No matches found",m.dim)];let{start:s,end:i}=jo(e,r);return n.slice(s,i).map((a,u)=>{let p=s+u===e;return
|
|
61
|
-
`):[]},Go=(t)=>{let e=[
|
|
62
|
-
`)),vt=t,tr=!1},Uo=(t,e)=>{oe(e+1),Vn(),Zn.write(t)},Jo=(t)=>{if(tr){Wo(t);return}if(t.forEach((n,r)=>{if(vt[r]!==n)Uo(n,r)}),t.length<vt.length)oe(t.length+1),$n();vt=t},zo=(t)=>{let e=Go(t);Jo(e)},Qo,ie=(t)=>{let e=Qo[t.mode];e(t)};var er=x(()=>{Ot();qn();vt=[],Fo=["String","Number","Boolean","null"],Mo=["Array","Object"],Qo={explore:zo,build:Kn,"build-arrow-fn":Xn}});var Ho,Ko,Xo,qo,Y=(t)=>{switch(t){case"Array":return Ho;case"String":return Ko;case"Object":return Xo;case"Number":return qo;default:return[]}};var nr=x(()=>{Ho=[{name:"map",signature:".map(x => ...)",description:"Transform each item",template:".map(x => x)",category:"Transform"},{name:"filter",signature:".filter(x => ...)",description:"Filter by condition",template:".filter(x => x)",category:"Filter"},{name:"reduce",signature:".reduce((acc, x) => ..., initial)",description:"Reduce to single value",template:".reduce((acc, x) => acc, 0)",category:"Aggregate"},{name:"find",signature:".find(x => ...)",description:"Find first match",template:".find(x => x)",category:"Search"},{name:"findIndex",signature:".findIndex(x => ...)",description:"Find first match index",template:".findIndex(x => x)",category:"Search"},{name:"some",signature:".some(x => ...)",description:"Check if any match",template:".some(x => x)",category:"Test"},{name:"every",signature:".every(x => ...)",description:"Check if all match",template:".every(x => x)",category:"Test"},{name:"sort",signature:".sort((a, b) => ...)",description:"Sort items",template:".sort((a, b) => a - b)",category:"Transform"},{name:"reverse",signature:".reverse()",description:"Reverse order",template:".reverse()",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Get subset",template:".slice(0, 10)",category:"Transform"},{name:"concat",signature:".concat(arr)",description:"Combine arrays",template:".concat([])",category:"Transform"},{name:"join",signature:".join(separator)",description:"Join to string",template:".join(', ')",category:"Convert"},{name:"flat",signature:".flat(depth)",description:"Flatten nested arrays",template:".flat(1)",category:"Transform"},{name:"flatMap",signature:".flatMap(x => ...)",description:"Map then flatten",template:".flatMap(x => x)",category:"Transform"},{name:"length",signature:".length",description:"Get array length",template:".length",category:"Property"}],Ko=[{name:"toUpperCase",signature:".toUpperCase()",description:"Convert to uppercase",template:".toUpperCase()",category:"Transform"},{name:"toLowerCase",signature:".toLowerCase()",description:"Convert to lowercase",template:".toLowerCase()",category:"Transform"},{name:"trim",signature:".trim()",description:"Remove whitespace",template:".trim()",category:"Transform"},{name:"trimStart",signature:".trimStart()",description:"Remove leading whitespace",template:".trimStart()",category:"Transform"},{name:"trimEnd",signature:".trimEnd()",description:"Remove trailing whitespace",template:".trimEnd()",category:"Transform"},{name:"split",signature:".split(separator)",description:"Split into array",template:".split(',')",category:"Convert"},{name:"replace",signature:".replace(search, replace)",description:"Replace first match",template:".replace('old', 'new')",category:"Transform"},{name:"replaceAll",signature:".replaceAll(search, replace)",description:"Replace all matches",template:".replaceAll('old', 'new')",category:"Transform"},{name:"substring",signature:".substring(start, end)",description:"Extract substring",template:".substring(0, 10)",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Extract slice",template:".slice(0, 10)",category:"Transform"},{name:"startsWith",signature:".startsWith(str)",description:"Check if starts with",template:".startsWith('prefix')",category:"Test"},{name:"endsWith",signature:".endsWith(str)",description:"Check if ends with",template:".endsWith('suffix')",category:"Test"},{name:"includes",signature:".includes(str)",description:"Check if contains",template:".includes('text')",category:"Test"},{name:"match",signature:".match(regex)",description:"Match regex pattern",template:".match(/pattern/)",category:"Search"},{name:"length",signature:".length",description:"Get string length",template:".length",category:"Property"}],Xo=[{name:"keys",signature:".{keys}",description:"Get object keys",template:".{keys}",category:"Convert"},{name:"values",signature:".{values}",description:"Get object values",template:".{values}",category:"Convert"},{name:"entries",signature:".{entries}",description:"Get key-value pairs",template:".{entries}",category:"Convert"},{name:"length",signature:".{length}",description:"Get property count",template:".{length}",category:"Property"}],qo=[{name:"toFixed",signature:".toFixed(decimals)",description:"Format with decimals",template:".toFixed(2)",category:"Format"},{name:"toString",signature:".toString()",description:"Convert to string",template:".toString()",category:"Convert"}]});var rr=(t)=>{let e=t.matches.length>0,n=t.selectedIndex>=0&&t.selectedIndex<t.matches.length;if(!e||!n)return t;let r=t.matches[t.selectedIndex].item,o={basePath:r.path,baseValue:r.value,baseType:r.type,expression:r.path,currentMethodIndex:0,arrowFnContext:null},s=Y(r.type),i=P(s,"",(a)=>a.signature);return Object.assign({},t,{mode:"build",builder:o,query:"",selectedIndex:0,methodMatches:i})},ct=(t)=>{return Object.assign({},t,{mode:"explore",builder:null,selectedIndex:0})},ce=(t,e)=>{if(!t.builder)return t;let r=t.builder,o=Y(r.baseType),s=P(o,e,(c)=>c.signature);return Object.assign({},t,{query:e,methodMatches:s,selectedIndex:0})},ae=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;let o=t.builder.arrowFnContext,s=P(o.paramPaths,e,(c)=>c.path);return Object.assign({},t,{query:e,propertyMatches:s,selectedIndex:0})},sr=(t,e)=>{if(!t.builder)return t;let r=t.builder;if(e<0||e>=t.methodMatches.length)return t;let i=t.methodMatches[e].item.template||"";if(i.includes("x =>")||i.includes("(a, b)")||i.includes("(acc, x)")){let h=r.baseType==="Array"?(()=>{if(!Array.isArray(r.baseValue))return{};if(r.baseValue.length===0)return{};return r.baseValue[0]})():r.baseValue,N=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",T=i.includes("(a, b)")?"a":"x",y=Nt(h),g={paramName:T,paramType:N,paramValue:h,paramPaths:y,expression:""},b=P(y,"",(S)=>S.path),R=Object.assign({},r,{currentMethodIndex:e,arrowFnContext:g,expression:r.expression+i});return Object.assign({},t,{mode:"build-arrow-fn",builder:R,query:"",selectedIndex:0,propertyMatches:b})}let a=r.expression+i,u=Object.assign({},r,{expression:a,currentMethodIndex:e});return Object.assign({},t,{builder:u})},or=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;if(e<0||e>=t.propertyMatches.length)return t;let s=t.builder,i=s.arrowFnContext,c=t.propertyMatches[e].item,a=i.paramName,u=c.path==="."?a:`${a}${c.path}`,l=Object.assign({},i,{expression:u}),p=Object.assign({},s,{arrowFnContext:l});return Object.assign({},t,{builder:p})},ir=(t)=>{let e=!t.builder,n=!t.builder?.arrowFnContext;if(e||n)return t;let r=t.builder,o=r.arrowFnContext;if(!o.expression)return t;let a=Y(r.baseType)[r.currentMethodIndex].template||"",u=(h,N,T)=>{let y=h.lastIndexOf(N);if(y===-1)return h;return h.substring(0,y)+T+h.substring(y+N.length)},l=r.expression;if(a.includes("x => x"))l=u(l,"x => x",`x => ${o.expression}`);else if(a.includes("(a, b) => a - b"))l=u(l,"(a, b) => a - b",`(a, b) => ${o.expression}`);else if(a.includes("(acc, x) => acc"))l=u(l,"(acc, x) => acc",`(acc, x) => ${o.expression}`);let p=Object.assign({},r,{expression:l,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:p,query:"",selectedIndex:0})},ue=(t)=>{if(!t.builder)return t;let n=t.builder,s=Y(n.baseType)[n.currentMethodIndex].template||"",i=n.expression.replace(s,""),c=Object.assign({},n,{expression:i,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:c})},cr=(t)=>{if(!t.builder)return t;let n=t.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return ct(t);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return ct(t);let a=Object.assign({},n,{expression:c}),u=Y(n.baseType),l=P(u,"",(d)=>d.signature);return Object.assign({},t,{builder:a,methodMatches:l,query:"",selectedIndex:0})};var ar=x(()=>{nr()});var I,Yo=(t)=>{let e=t===I.CTRL_C,n=t===I.ESCAPE;return e||n||t==="q"},le=(t)=>t===I.ENTER,pe=(t)=>t===I.TAB,de=(t)=>t===I.UP,he=(t)=>t===I.DOWN,ur=(t)=>t===I.LEFT,lr=(t)=>t===I.RIGHT,me=(t)=>t===I.BACKSPACE,fe=(t)=>{let e=t>=" ",n=t<="~";return e&&n},Zo=(t,e)=>{if(pe(e))return{state:rr(t),output:null};if(le(e)){let n=Dn(t);if(!n)return{state:null,output:null};return{state:null,output:JSON.stringify(n.value,null,2)}}if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:re(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:re(t,n),output:null}}return{state:t,output:null}},ti=(t,e)=>{if(e===I.ESCAPE)return{state:ct(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(lr(e)||pe(e)){if(!t.builder)return{state:t,output:null};return{state:sr(t,t.selectedIndex),output:null}}if(ur(e))return{state:cr(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ce(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ce(t,n),output:null}}return{state:t,output:null}},ei=(t,e)=>{if(e===I.ESCAPE)return{state:ue(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(lr(e)||pe(e)){let n=or(t,t.selectedIndex);return{state:ir(n),output:null}}if(ur(e))return{state:ue(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ae(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ae(t,n),output:null}}return{state:t,output:null}},ni,pr=(t,e)=>{let n=e.toString();if(Yo(n)){if(t.mode==="build"||t.mode==="build-arrow-fn")return{state:ct(t),output:null};return{state:null,output:null}}let r=ni[t.mode];return r(t,n)};var dr=x(()=>{se();ar();I=Object.assign({},{CTRL_C:"\x03",ESCAPE:"\x1B",ENTER:"\r",TAB:"\t",UP:"\x1B[A",DOWN:"\x1B[B",LEFT:"\x1B[D",RIGHT:"\x1B[C",BACKSPACE:"\x7F"}),ni={explore:Zo,build:ti,"build-arrow-fn":ei}});var hr={};O(hr,{runInteractive:()=>ii});import{stdin as ge,stdout as at,exit as ut}from"process";var xe=!1,It=()=>{if(xe)Wn(),Jn(),xe=!1;J()},be=(t)=>{It();let e=t instanceof Error?t.message:String(t),n=f(`Fatal error: ${e}
|
|
60
|
+
`.concat(f("\u2191/\u2193",m.bright)," navigate ",f("Enter",m.bright)," select ",f("Tab",m.bright)," build ",f("Esc/q",m.bright)," quit");return f(t,m.dim)},jo=(t,e)=>{let n=Math.floor(q/2),r=Math.max(0,t-n),o=Math.min(e,r+q);return{start:o-r<q&&e>=q?Math.max(0,o-q):r,end:o}},Do=(t)=>{let{selectedIndex:e,matches:n}=t,r=n.length;if(r===0)return[f("No matches found",m.dim)];let{start:s,end:i}=jo(e,r);return n.slice(s,i).map((a,u)=>{let p=s+u===e;return Ro(a,p)})},Vo=(t)=>{let e=t-q;return e>0?["",f("... "+e+" more",m.dim)]:[]},$o=(t)=>{let e=_o(t);return e?e.split(`
|
|
61
|
+
`):[]},Go=(t)=>{let e=[Co(),"","Search: "+t.query,""],n=Do(t),r=Vo(t.matches.length),o=$o(t),s=["",Bo().trim()];return[...e,...n,...r,...o,...s]},Wo=(t)=>{J(),Zn.write(t.join(`
|
|
62
|
+
`)),vt=t,tr=!1},Uo=(t,e)=>{oe(e+1),Vn(),Zn.write(t)},Jo=(t)=>{if(tr){Wo(t);return}if(t.forEach((n,r)=>{if(vt[r]!==n)Uo(n,r)}),t.length<vt.length)oe(t.length+1),$n();vt=t},zo=(t)=>{let e=Go(t);Jo(e)},Qo,ie=(t)=>{let e=Qo[t.mode];e(t)};var er=x(()=>{Ot();qn();vt=[],Fo=["String","Number","Boolean","null"],Mo=["Array","Object"],Qo={explore:zo,build:Kn,"build-arrow-fn":Xn}});var Ho,Ko,Xo,qo,Y=(t)=>{switch(t){case"Array":return Ho;case"String":return Ko;case"Object":return Xo;case"Number":return qo;default:return[]}};var nr=x(()=>{Ho=[{name:"map",signature:".map(x => ...)",description:"Transform each item",template:".map(x => x)",category:"Transform"},{name:"filter",signature:".filter(x => ...)",description:"Filter by condition",template:".filter(x => x)",category:"Filter"},{name:"reduce",signature:".reduce((acc, x) => ..., initial)",description:"Reduce to single value",template:".reduce((acc, x) => acc, 0)",category:"Aggregate"},{name:"find",signature:".find(x => ...)",description:"Find first match",template:".find(x => x)",category:"Search"},{name:"findIndex",signature:".findIndex(x => ...)",description:"Find first match index",template:".findIndex(x => x)",category:"Search"},{name:"some",signature:".some(x => ...)",description:"Check if any match",template:".some(x => x)",category:"Test"},{name:"every",signature:".every(x => ...)",description:"Check if all match",template:".every(x => x)",category:"Test"},{name:"sort",signature:".sort((a, b) => ...)",description:"Sort items",template:".sort((a, b) => a - b)",category:"Transform"},{name:"reverse",signature:".reverse()",description:"Reverse order",template:".reverse()",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Get subset",template:".slice(0, 10)",category:"Transform"},{name:"concat",signature:".concat(arr)",description:"Combine arrays",template:".concat([])",category:"Transform"},{name:"join",signature:".join(separator)",description:"Join to string",template:".join(', ')",category:"Convert"},{name:"flat",signature:".flat(depth)",description:"Flatten nested arrays",template:".flat(1)",category:"Transform"},{name:"flatMap",signature:".flatMap(x => ...)",description:"Map then flatten",template:".flatMap(x => x)",category:"Transform"},{name:"length",signature:".length",description:"Get array length",template:".length",category:"Property"}],Ko=[{name:"toUpperCase",signature:".toUpperCase()",description:"Convert to uppercase",template:".toUpperCase()",category:"Transform"},{name:"toLowerCase",signature:".toLowerCase()",description:"Convert to lowercase",template:".toLowerCase()",category:"Transform"},{name:"trim",signature:".trim()",description:"Remove whitespace",template:".trim()",category:"Transform"},{name:"trimStart",signature:".trimStart()",description:"Remove leading whitespace",template:".trimStart()",category:"Transform"},{name:"trimEnd",signature:".trimEnd()",description:"Remove trailing whitespace",template:".trimEnd()",category:"Transform"},{name:"split",signature:".split(separator)",description:"Split into array",template:".split(',')",category:"Convert"},{name:"replace",signature:".replace(search, replace)",description:"Replace first match",template:".replace('old', 'new')",category:"Transform"},{name:"replaceAll",signature:".replaceAll(search, replace)",description:"Replace all matches",template:".replaceAll('old', 'new')",category:"Transform"},{name:"substring",signature:".substring(start, end)",description:"Extract substring",template:".substring(0, 10)",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Extract slice",template:".slice(0, 10)",category:"Transform"},{name:"startsWith",signature:".startsWith(str)",description:"Check if starts with",template:".startsWith('prefix')",category:"Test"},{name:"endsWith",signature:".endsWith(str)",description:"Check if ends with",template:".endsWith('suffix')",category:"Test"},{name:"includes",signature:".includes(str)",description:"Check if contains",template:".includes('text')",category:"Test"},{name:"match",signature:".match(regex)",description:"Match regex pattern",template:".match(/pattern/)",category:"Search"},{name:"length",signature:".length",description:"Get string length",template:".length",category:"Property"}],Xo=[{name:"keys",signature:".{keys}",description:"Get object keys",template:".{keys}",category:"Convert"},{name:"values",signature:".{values}",description:"Get object values",template:".{values}",category:"Convert"},{name:"entries",signature:".{entries}",description:"Get key-value pairs",template:".{entries}",category:"Convert"},{name:"length",signature:".{length}",description:"Get property count",template:".{length}",category:"Property"}],qo=[{name:"toFixed",signature:".toFixed(decimals)",description:"Format with decimals",template:".toFixed(2)",category:"Format"},{name:"toString",signature:".toString()",description:"Convert to string",template:".toString()",category:"Convert"}]});var rr=(t)=>{let e=t.matches.length>0,n=t.selectedIndex>=0&&t.selectedIndex<t.matches.length;if(!e||!n)return t;let r=t.matches[t.selectedIndex].item,o={basePath:r.path,baseValue:r.value,baseType:r.type,expression:r.path,currentMethodIndex:0,arrowFnContext:null},s=Y(r.type),i=P(s,"",(a)=>a.signature);return Object.assign({},t,{mode:"build",builder:o,query:"",selectedIndex:0,methodMatches:i})},ct=(t)=>{return Object.assign({},t,{mode:"explore",builder:null,selectedIndex:0})},ce=(t,e)=>{if(!t.builder)return t;let r=t.builder,o=Y(r.baseType),s=P(o,e,(c)=>c.signature);return Object.assign({},t,{query:e,methodMatches:s,selectedIndex:0})},ae=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;let o=t.builder.arrowFnContext,s=P(o.paramPaths,e,(c)=>c.path);return Object.assign({},t,{query:e,propertyMatches:s,selectedIndex:0})},sr=(t,e)=>{if(!t.builder)return t;let r=t.builder;if(e<0||e>=t.methodMatches.length)return t;let i=t.methodMatches[e].item.template||"";if(i.includes("x =>")||i.includes("(a, b)")||i.includes("(acc, x)")){let h=r.baseType==="Array"?(()=>{if(!Array.isArray(r.baseValue))return{};if(r.baseValue.length===0)return{};return r.baseValue[0]})():r.baseValue,N=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",T=i.includes("(a, b)")?"a":"x",y=Nt(h),g={paramName:T,paramType:N,paramValue:h,paramPaths:y,expression:""},b=P(y,"",(S)=>S.path),C=Object.assign({},r,{currentMethodIndex:e,arrowFnContext:g,expression:r.expression+i});return Object.assign({},t,{mode:"build-arrow-fn",builder:C,query:"",selectedIndex:0,propertyMatches:b})}let a=r.expression+i,u=Object.assign({},r,{expression:a,currentMethodIndex:e});return Object.assign({},t,{builder:u})},or=(t,e)=>{let n=!t.builder,r=!t.builder?.arrowFnContext;if(n||r)return t;if(e<0||e>=t.propertyMatches.length)return t;let s=t.builder,i=s.arrowFnContext,c=t.propertyMatches[e].item,a=i.paramName,u=c.path==="."?a:`${a}${c.path}`,l=Object.assign({},i,{expression:u}),p=Object.assign({},s,{arrowFnContext:l});return Object.assign({},t,{builder:p})},ir=(t)=>{let e=!t.builder,n=!t.builder?.arrowFnContext;if(e||n)return t;let r=t.builder,o=r.arrowFnContext;if(!o.expression)return t;let a=Y(r.baseType)[r.currentMethodIndex].template||"",u=(h,N,T)=>{let y=h.lastIndexOf(N);if(y===-1)return h;return h.substring(0,y)+T+h.substring(y+N.length)},l=r.expression;if(a.includes("x => x"))l=u(l,"x => x",`x => ${o.expression}`);else if(a.includes("(a, b) => a - b"))l=u(l,"(a, b) => a - b",`(a, b) => ${o.expression}`);else if(a.includes("(acc, x) => acc"))l=u(l,"(acc, x) => acc",`(acc, x) => ${o.expression}`);let p=Object.assign({},r,{expression:l,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:p,query:"",selectedIndex:0})},ue=(t)=>{if(!t.builder)return t;let n=t.builder,s=Y(n.baseType)[n.currentMethodIndex].template||"",i=n.expression.replace(s,""),c=Object.assign({},n,{expression:i,arrowFnContext:null});return Object.assign({},t,{mode:"build",builder:c})},cr=(t)=>{if(!t.builder)return t;let n=t.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return ct(t);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return ct(t);let a=Object.assign({},n,{expression:c}),u=Y(n.baseType),l=P(u,"",(d)=>d.signature);return Object.assign({},t,{builder:a,methodMatches:l,query:"",selectedIndex:0})};var ar=x(()=>{nr()});var I,Yo=(t)=>{let e=t===I.CTRL_C,n=t===I.ESCAPE;return e||n||t==="q"},le=(t)=>t===I.ENTER,pe=(t)=>t===I.TAB,de=(t)=>t===I.UP,he=(t)=>t===I.DOWN,ur=(t)=>t===I.LEFT,lr=(t)=>t===I.RIGHT,me=(t)=>t===I.BACKSPACE,fe=(t)=>{let e=t>=" ",n=t<="~";return e&&n},Zo=(t,e)=>{if(pe(e))return{state:rr(t),output:null};if(le(e)){let n=Dn(t);if(!n)return{state:null,output:null};return{state:null,output:JSON.stringify(n.value,null,2)}}if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:re(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:re(t,n),output:null}}return{state:t,output:null}},ti=(t,e)=>{if(e===I.ESCAPE)return{state:ct(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(lr(e)||pe(e)){if(!t.builder)return{state:t,output:null};return{state:sr(t,t.selectedIndex),output:null}}if(ur(e))return{state:cr(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ce(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ce(t,n),output:null}}return{state:t,output:null}},ei=(t,e)=>{if(e===I.ESCAPE)return{state:ue(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(lr(e)||pe(e)){let n=or(t,t.selectedIndex);return{state:ir(n),output:null}}if(ur(e))return{state:ue(t),output:null};if(de(e))return{state:U(t,-1),output:null};if(he(e))return{state:U(t,1),output:null};if(me(e)){let n=t.query.slice(0,-1);return{state:ae(t,n),output:null}}if(fe(e)){let n=t.query.concat(e);return{state:ae(t,n),output:null}}return{state:t,output:null}},ni,pr=(t,e)=>{let n=e.toString();if(Yo(n)){if(t.mode==="build"||t.mode==="build-arrow-fn")return{state:ct(t),output:null};return{state:null,output:null}}let r=ni[t.mode];return r(t,n)};var dr=x(()=>{se();ar();I=Object.assign({},{CTRL_C:"\x03",ESCAPE:"\x1B",ENTER:"\r",TAB:"\t",UP:"\x1B[A",DOWN:"\x1B[B",LEFT:"\x1B[D",RIGHT:"\x1B[C",BACKSPACE:"\x7F"}),ni={explore:Zo,build:ti,"build-arrow-fn":ei}});var hr={};O(hr,{runInteractive:()=>ii});import{stdin as ge,stdout as at,exit as ut}from"process";var xe=!1,It=()=>{if(xe)Wn(),Jn(),xe=!1;J()},be=(t)=>{It();let e=t instanceof Error?t.message:String(t),n=f(`Fatal error: ${e}
|
|
63
63
|
`,m.yellow);at.write(n),ut(1)},ri=()=>{process.on("uncaughtException",be),process.on("unhandledRejection",be),process.on("SIGINT",()=>{It(),ut(0)}),process.on("SIGTERM",()=>{It(),ut(0)})},si=(t,e)=>{return pr(t,e)},oi=async(t)=>{let e=t;return new Promise((n)=>{let r=(o)=>{let{state:s,output:i}=si(e,o);if(i!==null){ge.off("data",r),n(i);return}if(s===null){ge.off("data",r),n(null);return}e=s,ie(e)};ge.on("data",r)})},ii=async(t)=>{ri();let e=Nt(t);if(!(e.length>0)){let o=f(`No paths found in data
|
|
64
64
|
`,m.yellow);at.write(o),ut(1)}let r=jn(e,t);Un(),xe=!0,Gn(),ie(r);try{let o=await oi(r);if(It(),o!==null)try{let i=ot(o),a=new et(i).tokenize(),l=new nt(a).parse(),d=new rt().evaluate(l,t),h=JSON.stringify(d,null,2);at.write(h),at.write(`
|
|
65
65
|
`)}catch(i){let c=i instanceof Error?i.message:String(i);at.write(f("Error: "+c+`
|
|
66
|
-
`,m.yellow))}ut(0)}catch(o){be(o)}};var mr=x(()=>{se();er();dr();Ot();zt();Ht();Yt();Et()});var ye=["json","yaml","csv","table"],Se=["json","yaml","toml","csv","tsv","lines","text"],yr=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var
|
|
66
|
+
`,m.yellow))}ut(0)}catch(o){be(o)}};var mr=x(()=>{se();er();dr();Ot();zt();Ht();Yt();Et()});var ye=["json","yaml","csv","table"],Se=["json","yaml","toml","csv","tsv","lines","text"],yr=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var Rt=(t,e)=>{let r=yr.filter((o)=>o.type===t).map((o)=>` ${o.short.padEnd(6)} -> ${o.full.padEnd(14)} ${o.description}`);return`${e}:
|
|
67
67
|
${r.join(`
|
|
68
68
|
`)}`},di=`Expression Shortcuts:
|
|
69
69
|
|
|
70
|
-
${
|
|
70
|
+
${Rt("array","Array Methods")}
|
|
71
71
|
|
|
72
|
-
${
|
|
72
|
+
${Rt("object","Object Methods")}
|
|
73
73
|
|
|
74
|
-
${
|
|
75
|
-
`;var we=ye,Ee=[...Se],Ae={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function Te(t){let e={...Ae},n=0;while(n<t.length){let r=t[n];switch(r){case"--help":case"-h":e.help=!0;break;case"--version":case"-v":e.version=!0;break;case"--raw":case"-r":e.raw=!0;break;case"--pretty":case"-p":e.pretty=!0;break;case"--compact":case"-c":e.compact=!0;break;case"--type":case"-t":e.type=!0;break;case"--format":if(n++,n<t.length){let s=t[n],i=we.includes(s);if(s&&i)e.format=s}break;case"--input-format":case"-if":if(n++,n<t.length){let s=t[n];if(Ee.includes(s))e.inputFormat=s}break;case"readFile":e.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<t.length)e.find=t[n];break;case"--grep":case"-g":if(n++,n<t.length)e.grep=t[n];break;case"--list":case"-l":if(n++,n<t.length)e.list=t[n];break;case"--recursive":case"-R":e.recursive=!0;break;case"--interactive":e.interactive=!0;break;case"--ignore-case":case"-i":e.ignoreCase=!0;break;case"--line-numbers":case"-n":e.showLineNumbers=!0;break;case"--ext":if(n++,n<t.length){let s=t[n].split(",");e.extensions=s.map((i)=>i.startsWith(".")?i:`.${i}`)}break;case"--max-depth":if(n++,n<t.length)e.maxDepth=parseInt(t[n],10);break;case"--shorten":if(n++,n<t.length)e.shorten=t[n];break;case"--expand":if(n++,n<t.length)e.expand=t[n];break;case"--shortcuts":e.shortcuts=!0;break;case"--detect":e.detect=!0;break;default:if(r.startsWith(".")||r.startsWith("["))e.expression=r;break}n++}return e}function
|
|
74
|
+
${Rt("string","String Methods")}
|
|
75
|
+
`;var we=ye,Ee=[...Se],Ae={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function Te(t){let e={...Ae},n=0;while(n<t.length){let r=t[n];switch(r){case"--help":case"-h":e.help=!0;break;case"--version":case"-v":e.version=!0;break;case"--raw":case"-r":e.raw=!0;break;case"--pretty":case"-p":e.pretty=!0;break;case"--compact":case"-c":e.compact=!0;break;case"--type":case"-t":e.type=!0;break;case"--format":if(n++,n<t.length){let s=t[n],i=we.includes(s);if(s&&i)e.format=s}break;case"--input-format":case"-if":if(n++,n<t.length){let s=t[n];if(Ee.includes(s))e.inputFormat=s}break;case"readFile":e.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<t.length)e.find=t[n];break;case"--grep":case"-g":if(n++,n<t.length)e.grep=t[n];break;case"--list":case"-l":if(n++,n<t.length)e.list=t[n];break;case"--recursive":case"-R":e.recursive=!0;break;case"--interactive":e.interactive=!0;break;case"--ignore-case":case"-i":e.ignoreCase=!0;break;case"--line-numbers":case"-n":e.showLineNumbers=!0;break;case"--ext":if(n++,n<t.length){let s=t[n].split(",");e.extensions=s.map((i)=>i.startsWith(".")?i:`.${i}`)}break;case"--max-depth":if(n++,n<t.length)e.maxDepth=parseInt(t[n],10);break;case"--shorten":if(n++,n<t.length)e.shorten=t[n];break;case"--expand":if(n++,n<t.length)e.expand=t[n];break;case"--shortcuts":e.shortcuts=!0;break;case"--detect":e.detect=!0;break;default:if(r.startsWith(".")||r.startsWith("["))e.expression=r;break}n++}return e}function Ct(){console.log(`
|
|
76
76
|
1ls - 1 line script for JSON manipulation and file operations
|
|
77
77
|
|
|
78
78
|
Usage:
|
|
@@ -156,4 +156,4 @@ ${i}`;return`${n}${o}: ${i}`}).join(`
|
|
|
156
156
|
`)}escapeCsvValue(t){if(t===null||t===void 0)return"";let e=String(t);if(e.includes(",")||e.includes('"')||e.includes(`
|
|
157
157
|
`))return`"${e.replace(/"/g,'""')}"`;return e}formatTable(t){if(!Array.isArray(t))return this.formatJson(t);if(t.length===0)return"(empty array)";if(typeof t[0]==="object"&&t[0]!==null&&!Array.isArray(t[0]))return this.formatObjectTable(t);return t.map((e,n)=>`${n}: ${this.formatRaw(e)}`).join(`
|
|
158
158
|
`)}formatObjectTable(t){let e=[...new Set(t.flatMap((i)=>Object.keys(i)))],n={};e.forEach((i)=>{n[i]=Math.max(i.length,...t.map((c)=>String(c[i]??"").length))});let r=e.map((i)=>i.padEnd(n[i])).join(" | "),o=e.map((i)=>"-".repeat(n[i])).join("-+-"),s=t.map((i)=>e.map((c)=>String(i[c]??"").padEnd(n[c])).join(" | "));return[r,o,...s].join(`
|
|
159
|
-
`)}}Et();xt();var ci=()=>Promise.resolve().then(() => (mr(),hr));async function ai(t){let e=await xn(t.grep,t.find,{recursive:t.recursive,ignoreCase:t.ignoreCase,showLineNumbers:t.showLineNumbers});if(e.length===0){console.log(Ln("No matches found"));return}for(let n of e){let r=`${Zt(n.file)}:${n.line}:${n.column}`,o=t.showLineNumbers?`${r}: ${n.match}`:`${Zt(n.file)}: ${n.match}`;console.log(o)}}async function ui(t,e){if(t.readFile){let s=e[e.indexOf("readFile")+1],i=await yt(s);return t.expression=e[e.indexOf("readFile")+2]||".",i}let n=!process.stdin.isTTY,r=t.list||t.grep;if(!n&&!r)
|
|
159
|
+
`)}}Et();xt();var ci=()=>Promise.resolve().then(() => (mr(),hr));async function ai(t){let e=await xn(t.grep,t.find,{recursive:t.recursive,ignoreCase:t.ignoreCase,showLineNumbers:t.showLineNumbers});if(e.length===0){console.log(Ln("No matches found"));return}for(let n of e){let r=`${Zt(n.file)}:${n.line}:${n.column}`,o=t.showLineNumbers?`${r}: ${n.match}`:`${Zt(n.file)}: ${n.match}`;console.log(o)}}async function ui(t,e){if(t.readFile){let s=e[e.indexOf("readFile")+1],i=await yt(s);return t.expression=e[e.indexOf("readFile")+2]||".",i}let n=!process.stdin.isTTY,r=t.list||t.grep;if(!n&&!r)Ct(),process.exit(1);if(n)return await pn(t.inputFormat);return null}async function fr(t,e){if(!t.expression){let n=new st(t);console.log(n.format(e));return}try{let n=ot(t.expression),o=new et(n).tokenize(),i=new nt(o).parse(),a=new rt().evaluate(i,e),u=new st(t);console.log(u.format(a))}catch(n){let r=n instanceof Error?n.message:String(n);console.error("Error:",r),process.exit(1)}}async function li(t){let e=Te(t);if(e.help)Ct(),process.exit(0);if(e.version){let r=await Bun.file("package.json").json();console.log(`1ls version ${r.version}`),process.exit(0)}if(e.shortcuts)console.log(Bn()),process.exit(0);if(e.shorten)console.log(_n(e.shorten)),process.exit(0);if(e.expand)console.log(ot(e.expand)),process.exit(0);if(e.detect){if(!!process.stdin.isTTY)console.error("Error: --detect requires input from stdin"),process.exit(1);let o=await Bun.stdin.text(),s=Gt(o);console.log(s),process.exit(0)}if(e.list){let r=await Ut(e.list,{recursive:e.recursive,extensions:e.extensions,maxDepth:e.maxDepth});console.log(new st(e).format(r));return}if(e.grep&&e.find){await ai(e);return}if(e.readFile){let r=t[t.indexOf("readFile")+1],o=await yt(r),s=t[t.indexOf("readFile")+2]||".",i=s===".";if(e.interactive||i){let{runInteractive:a}=await ci();await a(o);return}e.expression=s,await fr(e,o);return}if(e.interactive)console.error("Error: Interactive mode requires a file path. Use: 1ls readFile <path>"),process.exit(1);let n=await ui(e,t);await fr(e,n)}if(import.meta.main)li(process.argv.slice(2)).catch((t)=>{console.error("Error:",t.message),process.exit(1)});export{fr as processExpression,li as main,ui as loadData,ai as handleGrepOperation,ci as getInteractive};
|