1ls 0.1.11 → 0.1.12
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 +2 -0
- package/dist/browser/index.js +5 -5
- package/dist/index.js +41 -38
- package/dist/navigator/json.d.ts +5 -0
- package/dist/types.d.ts +1 -0
- package/dist/version.d.ts +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -476,3 +476,5 @@ MIT © Jeff Wainwright
|
|
|
476
476
|
- [GitHub Repository](https://github.com/yowainwright/1ls)
|
|
477
477
|
- [Documentation](https://1ls.dev)
|
|
478
478
|
- [Issue Tracker](https://github.com/yowainwright/1ls/issues)
|
|
479
|
+
|
|
480
|
+
<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=500dd7ce-0f58-4763-b6a7-fc992b6a12cb" />
|
package/dist/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var q={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},Z="+-*/%<>!&|=",tt=[" ","\t",`
|
|
2
|
-
`,"\r"];function v(t,e,n){return{type:t,value:e,position:n}}class _{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(v("EOF","",this.position)),t}nextToken(){let t=this.position,e=q[this.current];if(e){let h=this.current;return this.advance(),v(e,h,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),v("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let s=this.isDigit(this.current),o=this.current==="-"&&this.isDigit(this.peek());if(s||o)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 v("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 v("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return v("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return v("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 tt.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 Z.includes(t)}}var T=(t)=>{return{type:"Literal",value:t}},P=(t)=>{if(t==="true")return T(!0);if(t==="false")return T(!1);if(t==="null")return T(null);return};function E(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function b(t,e){return{type:"PropertyAccess",property:t,object:e}}function ft(t,e){return{type:"IndexAccess",index:t,object:e}}function mt(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function et(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function At(t,e){return{type:"ObjectOperation",operation:t,object:e}}function yt(t){return{type:"ArraySpread",object:t}}function gt(t,e){return{type:"ArrowFunction",params:t,body:e}}function I(t){return{type:"Root",expression:t}}var nt=["keys","values","entries","length"];function Tt(t){return nt.includes(t)}class M{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return I();let e=this.parseExpression();return I(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(),T(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(E(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),yt(t);if(this.current.type==="STRING"){let a=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),b(a,t)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(t);throw Error(E(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"),ft(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),mt(t,o,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(E(this.current,"Expected operation name after {"));let n=this.current.value;if(!Tt(n)){let r=nt.join(", ");throw Error(E(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),At(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=P(t);if(n)return n;return b(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return gt(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=et(`__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(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(E(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=P(t);if(e)return e;let n=b(t),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let a=n,u=a.property,h=a.object;n=this.parseMethodCall(h?h:I(),u);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=b(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),et(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 b(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(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 o=e.property;e=this.parseMethodCall(I(),o);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 b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(E(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(E(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var Nt={"+":(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};function rt(t){return t.startsWith("__operator_")&&t.endsWith("__")}function st(t){return t.slice(11,-2)}function ot(t,e,n){let r=Nt[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function Et(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function j(t){return Object.values(t)[0]}function ct(t){return t!==null&&typeof t==="object"}function B(t,e){if(!ct(t))return;return t[e]}function D(t,e){return t<0?e+t:t}function xt(t,e){if(!Array.isArray(t))return;let n=D(e,t.length);return t[n]}function Ot(t,e,n){if(!Array.isArray(t))return;let r=t.length,s=e!==void 0?D(e,r):0,o=n!==void 0?D(n,r):r;return t.slice(s,o)}function vt(t,e){if(!ct(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}}var bt=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},St=(t)=>t instanceof Error?t.message:String(t);function it(t,e,n){if(!bt(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(s){let o=St(s);throw Error(`Error executing method ${e}: ${o}`)}}class G{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 xt(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return Ot(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 vt(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 B(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(rt(t.method)){let o=st(t.method),i=this.evaluate(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateArg(o,e));return it(n,t.method,s)}createFunction(t){return(...e)=>{let n=Et(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,j(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let o=this.evaluateFunctionBody(t.object,e);return B(o,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let s=j(e);return B(s,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):j(e);if(rt(t.method)){let o=st(t.method),i=this.evaluateFunctionBody(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateFunctionBody(o,e));return it(n,t.method,s)}}var U=[{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 W=(t,e)=>{let r=U.filter((s)=>s.type===t).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${e}:
|
|
2
|
+
`,"\r"];function v(t,e,n){return{type:t,value:e,position:n}}class _{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(v("EOF","",this.position)),t}nextToken(){let t=this.position,e=q[this.current];if(e){let h=this.current;return this.advance(),v(e,h,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),v("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let s=this.isDigit(this.current),o=this.current==="-"&&this.isDigit(this.peek());if(s||o)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 v("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 v("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return v("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return v("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 tt.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 Z.includes(t)}}var T=(t)=>{return{type:"Literal",value:t}},P=(t)=>{if(t==="true")return T(!0);if(t==="false")return T(!1);if(t==="null")return T(null);return};function E(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function b(t,e){return{type:"PropertyAccess",property:t,object:e}}function ft(t,e){return{type:"IndexAccess",index:t,object:e}}function mt(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function et(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function At(t,e){return{type:"ObjectOperation",operation:t,object:e}}function yt(t){return{type:"ArraySpread",object:t}}function gt(t,e){return{type:"ArrowFunction",params:t,body:e}}function k(t){return{type:"Root",expression:t}}var nt=["keys","values","entries","length"];function Tt(t){return nt.includes(t)}class M{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return k();let e=this.parseExpression();return k(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT"){if(this.advance(),this.current.type==="EOF")return k();return 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(),T(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(E(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),yt(t);if(this.current.type==="STRING"){let a=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),b(a,t)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(t);throw Error(E(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"),ft(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),mt(t,o,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(E(this.current,"Expected operation name after {"));let n=this.current.value;if(!Tt(n)){let r=nt.join(", ");throw Error(E(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),At(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=P(t);if(n)return n;return b(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return gt(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=et(`__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(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(E(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=P(t);if(e)return e;let n=b(t),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let a=n,u=a.property,h=a.object;n=this.parseMethodCall(h?h:k(),u);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=b(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),et(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 b(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(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 o=e.property;e=this.parseMethodCall(k(),o);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 b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(E(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(E(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var Nt={"+":(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};function rt(t){return t.startsWith("__operator_")&&t.endsWith("__")}function st(t){return t.slice(11,-2)}function ot(t,e,n){let r=Nt[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function Et(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function j(t){return Object.values(t)[0]}function ct(t){return t!==null&&typeof t==="object"}function B(t,e){if(!ct(t))return;return t[e]}function D(t,e){return t<0?e+t:t}function xt(t,e){if(!Array.isArray(t))return;let n=D(e,t.length);return t[n]}function Ot(t,e,n){if(!Array.isArray(t))return;let r=t.length,s=e!==void 0?D(e,r):0,o=n!==void 0?D(n,r):r;return t.slice(s,o)}function vt(t,e){if(!ct(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}}var bt=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},St=(t)=>t instanceof Error?t.message:String(t);function it(t,e,n){if(!bt(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(s){let o=St(s);throw Error(`Error executing method ${e}: ${o}`)}}class G{options;constructor(t={}){this.options=t}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 xt(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return Ot(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 vt(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,r=B(n,t.property);if(this.options.strict&&r===void 0){let s=t.property;throw Error(`Property "${s}" is undefined`)}return r}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(rt(t.method)){let o=st(t.method),i=this.evaluate(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateArg(o,e));return it(n,t.method,s)}createFunction(t){return(...e)=>{let n=Et(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,j(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let o=this.evaluateFunctionBody(t.object,e);return B(o,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let s=j(e);return B(s,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):j(e);if(rt(t.method)){let o=st(t.method),i=this.evaluateFunctionBody(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateFunctionBody(o,e));return it(n,t.method,s)}}var U=[{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 W=(t,e)=>{let r=U.filter((s)=>s.type===t).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${e}:
|
|
3
3
|
${r.join(`
|
|
4
4
|
`)}`},Ne=`Expression Shortcuts:
|
|
5
5
|
|
|
@@ -8,8 +8,8 @@ ${W("array","Array Methods")}
|
|
|
8
8
|
${W("object","Object Methods")}
|
|
9
9
|
|
|
10
10
|
${W("string","String Methods")}
|
|
11
|
-
`;var at=/[.*+?^${}()|[\]\\]/g,V=U;var wt=/^-?\d+$/,Rt=/^[+-]?\d+$/,kt=/^-?\d+\.\d+$/,It=/^[+-]?\d+\.\d+$/;var
|
|
11
|
+
`;var at=/[.*+?^${}()|[\]\\]/g,V=U;var wt=/^-?\d+$/,Rt=/^[+-]?\d+$/,kt=/^-?\d+\.\d+$/,It=/^[+-]?\d+\.\d+$/;var $={INTEGER:wt,FLOAT:kt},H={INTEGER:Rt,FLOAT:It};var Ct=["true","yes","on"],Ft=["false","no","off"],Lt=["null","~",""],_t=(t)=>Ct.includes(t),Pt=(t)=>Ft.includes(t),Mt=(t)=>Lt.includes(t),C=(t)=>{if(_t(t))return!0;if(Pt(t))return!1;return},F=(t)=>{if(Mt(t))return null;return},ut=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};function jt(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 I(t){let{tag:e,content:n}=jt(t);if(e==="str")return n;let r=n.startsWith('"')&&n.endsWith('"'),s=n.startsWith("'")&&n.endsWith("'");if(r||s)return n.slice(1,-1);let i=C(n);if(i!==void 0)return i;let a=F(n);if(a!==void 0)return a;if($.INTEGER.test(n))return parseInt(n,10);if($.FLOAT.test(n))return parseFloat(n);if(n.startsWith("[")&&n.endsWith("]"))return n.slice(1,-1).split(",").map((c)=>I(c.trim()));if(n.startsWith("{")&&n.endsWith("}")){let c={};return n.slice(1,-1).split(",").forEach((J)=>{let[S,y]=J.split(":").map((p)=>p.trim());if(S&&y)c[S]=I(y)}),c}return n}function Bt(t,e){return Array.from({length:e},(r,s)=>e-1-s).reduce((r,s)=>{if(r!==null)return r;let o=t[s],i=o.indexOf("#");if(i>=0){let f=o.substring(0,i);if((f.match(/["']/g)||[]).length%2===0)o=f}let u=o.trim();if(u&&!u.startsWith("-")&&u.includes(":")){let f=u.indexOf(":"),g=u.substring(0,f).trim(),c=u.substring(f+1).trim();if(!c||c==="|"||c===">"||c==="|+"||c===">-")return g}return null},null)}function K(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 Dt(t){let e=t.indexOf(":");if(e<=0)return!1;let n=t.substring(0,e);return!n.includes(" ")||n.startsWith('"')||n.startsWith("'")}function Q(t){return t.length-t.trimStart().length}function Gt(t,e,n,r){let s=[],o=e;while(o<t.length){let a=t[o];if(!a.trim()){s.push(""),o++;continue}if(Q(a)<=n)break;s.push(a.substring(n+2)),o++}while(s.length>0&&s[s.length-1]==="")s.pop();return{value:r==="|"?s.join(`
|
|
12
12
|
`):s.join(" ").replace(/\s+/g," ").trim(),endIdx:o-1}}function Y(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)=>Y(n,e));if(typeof t==="object"&&t!==null){let n={};for(let[r,s]of Object.entries(t))if(r==="<<"&&typeof s==="string"&&s.startsWith("*")){let o=s.substring(1),i=e[o];if(typeof i==="object"&&i!==null&&!Array.isArray(i))Object.assign(n,i)}else n[r]=Y(s,e);return n}return t}function Wt(t){let e=t.trim().split(`
|
|
13
|
-
`),n={},o=e.find((h)=>{let f=K(h).trim();return f&&f!=="---"&&f!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:o,indent:-1}];function a(){return i[i.length-1]}function u(h){while(i.length>1&&h(a()))i.pop()}for(let h=0;h<e.length;h++){let f=e[h],g=K(f),c=g.trim();if(!c||c==="---"||c==="...")continue;let d=Q(g);if(c.startsWith("- ")||c==="-"){let y=c==="-"?"":c.substring(2).trim();u((A)=>A.indent>d||A.indent>=d&&!Array.isArray(A.container));let l,p=a();if(Array.isArray(p.container)&&(p.indent===d||p.indent===-1&&d===0)){if(l=p.container,p.indent===-1)p.indent=d}else{if(l=[],p.pendingKey)p.container[p.pendingKey]=l,p.pendingKey=void 0;else if(!Array.isArray(p.container)){let A=Bt(e,h);if(A)p.container[A]=l}i.push({container:l,indent:d})}if(Dt(y)){let A=y.indexOf(":"),m=y.substring(0,A).trim(),N=y.substring(A+1).trim(),x=null;if(m.includes(" &")){let w=m.split(" &");m=w[0],x=w[1]}let O={[m]:N?
|
|
14
|
-
`);if(n.length===0)return[];let r=pt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((s,o)=>{let i=pt(o,e);if(i.length===0)return s;let a=Object.fromEntries(r.map((u,h)=>[u,Ut(i[h]||"")]));return[...s,a]},[])}function z(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(
|
|
15
|
-
`),n={},r=n,s=[];return e.forEach((o)=>{let i=o,a=i.indexOf("#");if(a>=0){let c=i.substring(0,a);if((c.match(/["']/g)||[]).length%2===0)i=c}let u=i.trim();if(!u)return;if(u.startsWith("[")&&u.endsWith("]")){let c=u.slice(1,-1).split(".");r=n,s=[],c.forEach((d)=>{if(!r[d])r[d]={};r=r[d],s.push(d)});return}let f=u.indexOf("=");if(f>0){let c=u.substring(0,f).trim(),d=u.substring(f+1).trim();r[c]=z(d)}}),n}function lt(t){return t.replace(at,"\\$&")}var
|
|
13
|
+
`),n={},o=e.find((h)=>{let f=K(h).trim();return f&&f!=="---"&&f!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:o,indent:-1}];function a(){return i[i.length-1]}function u(h){while(i.length>1&&h(a()))i.pop()}for(let h=0;h<e.length;h++){let f=e[h],g=K(f),c=g.trim();if(!c||c==="---"||c==="...")continue;let d=Q(g);if(c.startsWith("- ")||c==="-"){let y=c==="-"?"":c.substring(2).trim();u((A)=>A.indent>d||A.indent>=d&&!Array.isArray(A.container));let l,p=a();if(Array.isArray(p.container)&&(p.indent===d||p.indent===-1&&d===0)){if(l=p.container,p.indent===-1)p.indent=d}else{if(l=[],p.pendingKey)p.container[p.pendingKey]=l,p.pendingKey=void 0;else if(!Array.isArray(p.container)){let A=Bt(e,h);if(A)p.container[A]=l}i.push({container:l,indent:d})}if(Dt(y)){let A=y.indexOf(":"),m=y.substring(0,A).trim(),N=y.substring(A+1).trim(),x=null;if(m.includes(" &")){let w=m.split(" &");m=w[0],x=w[1]}let O={[m]:N?I(N):null};if(l.push(O),x)n[x]=O;i.push({container:O,indent:d+2})}else if(y)l.push(I(y));else{let A={};l.push(A),i.push({container:A,indent:d+2})}continue}let S=c.indexOf(":");if(S>0){let y=c.substring(0,S).trim(),l=c.substring(S+1).trim(),p=null;if(l.startsWith("&")){let m=l.indexOf(" ");if(m>0)p=l.substring(1,m),l=l.substring(m+1);else p=l.substring(1),l=""}u((m)=>m.indent>d||m.indent===d&&Array.isArray(m.container));let L=a(),A=L.container;if(Array.isArray(A))continue;if(l==="|"||l===">"||l==="|+"||l===">-"||l==="|-"||l===">+"){let m=l.startsWith("|")?"|":">",{value:N,endIdx:x}=Gt(e,h+1,d,m);if(A[y]=N,p)n[p]=N;h=x}else if(l){let m=I(l);if(A[y]=m,p)n[p]=m}else{let m=h+1,N=m<e.length,x=N?K(e[m]):"",O=x.trim(),w=N?Q(x):-1,ht=O.startsWith("- ")||O==="-",dt=N&&w>d&&O;if(ht&&w>d){if(L.pendingKey=y,p){let R={};n[p]=R}}else if(dt){let R={};if(A[y]=R,p)n[p]=R;i.push({container:R,indent:w})}else if(A[y]=null,p)n[p]=null}}}return Y(o,n)}function pt(t,e){let n=[],r="",s=!1,o=t.split("");return o.forEach((i,a)=>{let u=o[a+1];if(i==='"'){if(s&&u==='"'){r+='"',o.splice(a+1,1);return}s=!s;return}if(i===e&&!s){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function Ut(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/""/g,'"');let r=ut(e);if(r!==void 0)return r;let s=e.toLowerCase(),o=C(s);if(o!==void 0)return o;let i=F(s);if(i!==void 0)return i;return e}function Vt(t,e=","){let n=t.trim().split(`
|
|
14
|
+
`);if(n.length===0)return[];let r=pt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((s,o)=>{let i=pt(o,e);if(i.length===0)return s;let a=Object.fromEntries(r.map((u,h)=>[u,Ut(i[h]||"")]));return[...s,a]},[])}function z(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(H.INTEGER.test(t))return parseInt(t,10);if(H.FLOAT.test(t))return parseFloat(t);if(t.startsWith("[")&&t.endsWith("]"))return t.slice(1,-1).split(",").map((u)=>z(u.trim()));if(t.startsWith("{")&&t.endsWith("}")){let a={};return t.slice(1,-1).split(",").forEach((h)=>{let[f,g]=h.split("=").map((c)=>c.trim());if(f&&g)a[f]=z(g)}),a}return t}function $t(t){let e=t.trim().split(`
|
|
15
|
+
`),n={},r=n,s=[];return e.forEach((o)=>{let i=o,a=i.indexOf("#");if(a>=0){let c=i.substring(0,a);if((c.match(/["']/g)||[]).length%2===0)i=c}let u=i.trim();if(!u)return;if(u.startsWith("[")&&u.endsWith("]")){let c=u.slice(1,-1).split(".");r=n,s=[],c.forEach((d)=>{if(!r[d])r[d]={};r=r[d],s.push(d)});return}let f=u.indexOf("=");if(f>0){let c=u.substring(0,f).trim(),d=u.substring(f+1).trim();r[c]=z(d)}}),n}function lt(t){return t.replace(at,"\\$&")}var Ht=V.map((t)=>({regex:new RegExp(`${lt(t.short)}(?![a-zA-Z])`,"g"),replacement:t.full})).sort((t,e)=>e.replacement.length-t.replacement.length),Kt=V.map((t)=>({regex:new RegExp(`${lt(t.full)}(?![a-zA-Z])`,"g"),replacement:t.short})).sort((t,e)=>e.regex.source.length-t.regex.source.length);function Qt(t){return Ht.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Ge(t){return Kt.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function We(t,e){let n=Qt(e),s=new _(n).tokenize(),i=new M(s).parse();return new G().evaluate(i,t)}export{Ge as shortenExpression,Wt as parseYAML,$t as parseTOML,Vt as parseCSV,Qt as expandShortcuts,We as evaluate,lt as escapeRegExp,_ as Lexer,G as JsonNavigator,M as ExpressionParser};
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
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
|
|
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
|
|
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(
|
|
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]=
|
|
8
|
-
`).reduce((r,o)=>Je(r,o),{result:{},currentSection:""}).result}var Qe=x(()=>{
|
|
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
|
|
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
|
|
11
|
-
return (${s})`;return Function(u)()}var
|
|
12
|
-
`).reduce((r,o)=>
|
|
13
|
-
`).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}function
|
|
14
|
-
`).filter((e)=>e.length>0)}async function
|
|
15
|
-
`)
|
|
16
|
-
|
|
17
|
-
`),
|
|
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=`
|
|
3
|
+
var yr=Object.defineProperty;var O=(t,e)=>{for(var n in e)yr(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 wr,Er,Ar,Nr,Te,Tr,Or,vr,Ir,Rr,Cr,Fr,Mr,Lr,kr,Pr,_r,Br,jr,Ft,Mt,M,Oe,Lt,Dr,$r,Vr,Gr,Wr,Ur,E;var $=x(()=>{wr=/^-?\d+$/,Er=/^[+-]?\d+$/,Ar=/^-?\d+\.\d+$/,Nr=/^[+-]?\d+\.\d+$/,Te=/^-?\d+(\.\d+)?$/,Tr=/(\w+)=["']([^"']+)["']/g,Or=/^<(\w+)([^>]*?)\/>/,vr=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,Ir=/<\w+/,Rr=/<\/\w+>$/,Cr=/^<\?xml[^>]+\?>\s*/,Fr=/,(\s*[}\]])/g,Mr=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,Lr=/\/\/|\/\*|,\s*[}\]]/,kr=/^\[[\w.\s]+\]$/m,Pr=/^\[[\w.]+\]$/m,_r=/^\w+\s*=\s*"[^"]*"$/m,Br=/=\s*["[{]/m,jr=/^\w+\s*=\s*.+$/m,Ft={INTEGER:wr,FLOAT:Ar},Mt={INTEGER:Er,FLOAT:Nr},M={NUMBER:Te,ATTRIBUTES:Tr,SELF_CLOSING:Or,OPEN_TAG:vr,NESTED_TAGS:Ir,COMPLETE_TAGS:Rr,XML_DECLARATION:Cr},Oe={NUMBER:Te},Lt={TRAILING_COMMA:Fr,UNQUOTED_KEY:Mr},Dr=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,$r=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,Vr=/^\s*interface\s+\w+/m,Gr=/^\s*type\s+\w+\s*=/m,Wr=/^[A-Z_][A-Z0-9_]*\s*=/m,Ur=/^\{.*\}\s*$/m,E={JSON5_FEATURES:Lr,SECTION_HEADER:kr,TOML_SECTION:Pr,TOML_QUOTED_VALUES:_r,TOML_SYNTAX:Br,INI_SYNTAX:jr,JS_EXPORT:Dr,TS_TYPE_ANNOTATION:$r,TS_INTERFACE:Vr,TS_TYPE_ALIAS:Gr,ENV_FEATURES:Wr,NDJSON_FEATURES:Ur}});var ke={};O(ke,{stripJSON5Comments:()=>Me,parseJSON5:()=>Jr,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 Jr(t){let e=Le(t);return JSON.parse(e)}var Pe=x(()=>{$()});var zr,Qr,Hr,Kr=(t)=>zr.includes(t),Xr=(t)=>Qr.includes(t),qr=(t)=>Hr.includes(t),Q=(t)=>{if(Kr(t))return!0;if(Xr(t))return!1;return},H=(t)=>{if(qr(t))return null;return},pt=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};var dt=x(()=>{zr=["true","yes","on"],Qr=["false","no","off"],Hr=["null","~",""]});var Be={};O(Be,{parseYAMLValue:()=>K,parseYAML:()=>es,findPreviousKey:()=>_e});function Yr(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}=Yr(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((T)=>{let[N,y]=T.split(":").map((b)=>b.trim());if(N&&y)d[N]=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 Zr(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 ts(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
|
+
`):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 es(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(Zr(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 N=d.indexOf(":");if(N>0){let y=d.substring(0,N).trim(),g=d.substring(N+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:_}=ts(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,xr=D.startsWith("- ")||D==="-",br=F&&z>h&&D;if(xr&&z>h){if(C.pendingKey=y,b){let Z={};n[b]=Z}}else if(br){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(()=>{$();dt()});var De={};O(De,{parseTOMLValue:()=>ht,parseTOML:()=>ns});function ht(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)=>ht(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]=ht(p)}),c}return t}function ns(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]=ht(h)}}),n}var $e=x(()=>{$()});var Ge={};O(Ge,{parseXMLValue:()=>tt,parseXMLElement:()=>Bt,parseXMLChildren:()=>Ve,parseXMLAttributes:()=>mt,parseXML:()=>os});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 mt(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:mt(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:mt(s),_text:tt(c)}};return{[o]:tt(c)}}let u=Ve(c);if(s.trim().length>0)return{[o]:{_attributes:mt(s),...u}};return{[o]:u}}function rs(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 T=e[c+1]==="/",y=t.slice(c).match(/^<[^>]+\/>/);if(T)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 ss(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 Ve(t){return rs(t).reduce((n,r)=>{let o=Bt(r);if(typeof o==="object"&&o!==null)Object.entries(o).forEach(([i,c])=>{ss(n,i,c)});return n},{})}function os(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(()=>{$()});var ze={};O(ze,{stripINIComments:()=>Ue,processINILine:()=>Je,parseINIValue:()=>jt,parseINI:()=>is});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 is(t){return t.trim().split(`
|
|
8
|
+
`).reduce((r,o)=>Je(r,o),{result:{},currentSection:""}).result}var Qe=x(()=>{$()});var $t={};O($t,{parseTSV:()=>cs,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=pt(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
|
+
`);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 cs(t){return Ke(t,"\t")}var Vt=x(()=>{dt()});var Xe={};O(Xe,{parseProtobufJSON:()=>us,parseProtobuf:()=>as});function as(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 us(t){return JSON.parse(t)}var nn={};O(nn,{stripJSComments:()=>ft,parseJavaScript:()=>ls,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 ft(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 ls(t){let e=ft(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:()=>ds});function ps(){if(gt!==null)return gt;return gt=new Bun.Transpiler({loader:"ts"}),gt}function ds(t){let e=ft(t),r=ps().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 gt=null;var sn=()=>{};var cn={};O(cn,{parseENVValue:()=>on,parseENV:()=>fs});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=pt(e);if(c!==void 0)return c;return e}function hs(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 ms(t,e){let r=hs(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 fs(t){return t.trim().split(`
|
|
12
|
+
`).reduce((r,o)=>ms(r,o),{result:{}}).result}var an=x(()=>{dt()});var un={};O(un,{parseNDJSON:()=>gs});function gs(t){return t.trim().split(`
|
|
13
|
+
`).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}function xs(t){return t.trim().split(`
|
|
14
|
+
`).filter((e)=>e.length>0)}async function xt(t,e){switch(e??Gt(t)){case"json":try{return JSON.parse(t)}catch(r){let o=t.length>50?t.slice(0,50)+"...":t;throw Error(`Invalid JSON: ${r.message}
|
|
15
|
+
Input: ${o}`)}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(() => ($e(),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(() => (Vt(),$t));return r(t)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (Vt(),$t));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 xs(t);case"text":default:{if(/^\s*[{[]/.test(t))try{return JSON.parse(t)}catch(o){let s=t.length>50?t.slice(0,50)+"...":t;throw Error(`Invalid JSON: ${o.message}
|
|
16
|
+
Input: ${s}`)}return t}}}function ys(t){let e=t.split(`
|
|
17
|
+
`),n=E.NDJSON_FEATURES.test(t),r=e.every(bs);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 Ss(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=Os(e,n,r);if(o)return o;let s=vs(e);if(s)return s;return"text"}var bs=(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,ws=(t)=>{try{return JSON.parse(t),"json"}catch{return E.JSON5_FEATURES.test(t)?"json5":null}},Es=(t,e,n)=>{if(e==="{"&&n==="}"||e==="["&&n==="]")return ws(t);return null},As=(t)=>{let e=t.startsWith("<?xml"),n=/<\/\w+>/.test(t);return e||n?"xml":null},Ns=(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 Ns(t)?"typescript":"javascript"},Os=(t,e,n)=>{switch(e){case"{":case"[":return Es(t,e,n);case"<":return As(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}},vs=(t)=>{if(t.includes("="))return Ss(t);let n=t.includes(": "),r=/^[\s]*-\s+/m.test(t);if(n||r)return"yaml";if(t.includes(`
|
|
18
|
+
`))return ys(t);return null};var bt=x(()=>{$()});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 xt(n,t)}var Wt=x(()=>{bt()});var Is,Rs,Cs,dn,hn;var yt=x(()=>{Is=[".ts",".js",".tsx",".jsx"],Rs=[".json",".yml",".yaml"],Cs=[".md",".txt"],dn=[...Is,...Rs,...Cs],hn=/[.*+?^${}()|[\]\\]/g});import{readdir as Fs,stat as mn}from"fs/promises";import{join as Ms,extname as Ls,basename as ks}from"path";async function St(t,e=!0){let r=await Bun.file(t).text();if(!e)return r;return xt(r)}function Ps(t,e){return{path:t,name:ks(t),ext:Ls(t),size:Number(e.size),isDirectory:e.isDirectory(),isFile:e.isFile(),modified:e.mtime,created:e.birthtime}}async function _s(t){let e=await mn(t);return Ps(t,e)}function Bs(t){return t.startsWith(".")}function js(t,e){return e||!Bs(t)}function Ds(t,e){if(e===void 0)return!0;return e.includes(t)}function $s(t,e){if(e===void 0)return!0;return e.test(t)}function Vs(t,e,n){let r=Ds(t.ext,e),o=$s(t.name,n);return r&&o}function Gs(t,e){return t<=(e??1/0)}async function Ws(t,e,n,r){if(!js(e,r.includeHidden??!1))return[];let s=Ms(t,e),i=await _s(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(!Gs(e,n.maxDepth))return[];let o=await Fs(t);return(await Promise.all(o.map((i)=>Ws(t,i,e,n)))).flat()}async function Ut(t,e={}){return fn(t,0,e)}function Us(t,e){if(typeof t!=="string")return t;return new RegExp(t,e?"gi":"g")}function Js(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 zs(t,e,n){if(!n)return;let r=e instanceof Error?e.message:String(e);console.error(`Failed to search ${t}: ${r}`)}function Qs(t,e,n,r,o,s){return[...t.matchAll(n)].map((c)=>Js(r,e,c.index,t,o,s))}async function gn(t,e,n){try{let r=await St(t,!1);if(typeof r!=="string")return[];let s=r.split(`
|
|
19
|
+
`),i=s.flatMap((a,u)=>Qs(a,u,e,t,s,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return zs(t,r,n.verbose??!1),[]}}async function Hs(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=Us(t,n.ignoreCase??!1),o=await mn(e);if(o.isFile())return gn(e,r,n);if(o.isDirectory()&&n.recursive)return Hs(e,r,n);return[]}var Jt=x(()=>{yt();bt()});var wt=()=>{};var yn,Sn="+-*/%<>!&|=",wn;var En=x(()=>{wt();yn={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},wn=[" ","\t",`
|
|
20
|
+
`,"\r"]});function V(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(V("EOF","",this.position)),t}nextToken(){let t=this.position,e=yn[this.current];if(e){let u=this.current;return this.advance(),V(e,u,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),V("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 V("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 V("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return V("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return V("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(()=>{wt();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 Nn=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 Ks(t,e){return{type:"IndexAccess",index:t,object:e}}function Xs(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function Tn(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function qs(t,e){return{type:"ObjectOperation",operation:t,object:e}}function Ys(t){return{type:"ArraySpread",object:t}}function Zs(t,e){return{type:"ArrowFunction",params:t,body:e}}function nt(t){return{type:"Root",expression:t}}function to(t){return On.includes(t)}class rt{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return nt();let e=this.parseExpression();return nt(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT"){if(this.advance(),this.current.type==="EOF")return nt();return 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(),Ys(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"),Ks(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"),Xs(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(!to(n)){let r=On.join(", ");throw Error(k(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),qs(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 Zs(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=Tn(`__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:nt(),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"),Tn(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(nt(),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(()=>{wt();Nn();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=eo[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function no(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 ro(t,e){if(!Array.isArray(t))return;let n=qt(e,t.length);return t[n]}function so(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 oo(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(!io(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(o){let s=co(o);throw Error(`Error executing method ${e}: ${s}`)}}class st{options;constructor(t={}){this.options=t}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 ro(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return so(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 oo(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,r=Xt(n,t.property);if(this.options.strict&&r===void 0){let o=t.property;throw Error(`Property "${o}" is undefined`)}return r}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=no(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 eo,io=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},co=(t)=>t instanceof Error?t.message:String(t);var Yt=x(()=>{eo={"+":(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 uo,Sc;var kn=x(()=>{te();uo={ERROR:W.ERROR,WARN:W.WARN,INFO:W.INFO,DEBUG:W.DEBUG},Sc=process.env.LOG_LEVEL?uo[process.env.LOG_LEVEL]||W.INFO:W.INFO});function ee(t){return t.replace(hn,"\\$&")}var Pn=x(()=>{yt();yt();Jt();kn();Et();Wt();te()});function it(t){return lo.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function _n(t){return po.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
21
|
${s}:
|
|
20
22
|
`,l=i.map((p)=>` ${p.short.padEnd(c+2)} \u2192 ${p.full.padEnd(a+2)} # ${p.description}`).join(`
|
|
21
23
|
`);return u+l};return`
|
|
@@ -31,48 +33,48 @@ Examples:
|
|
|
31
33
|
|
|
32
34
|
1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
|
|
33
35
|
1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
|
|
34
|
-
`}var B,
|
|
36
|
+
`}var B,Fc,Mc,lo,po;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"}],Fc=new Map(B.map((t)=>[t.short,t.full])),Mc=new Map(B.map((t)=>[t.full,t.short])),lo=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),po=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)},Nt=(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=Nt(t,i);return n.push({path:e||".",value:t,type:i,displayValue:c}),n}if(Array.isArray(t)){let i=At(t),c=Nt(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=Nt(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=Nt(t,r),s=e||".";return n.push({path:s,value:t,type:r,displayValue:o}),n},Tt=(t)=>{return ne(t)};var ho=(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},mo=(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},fo=(t,e,n)=>{let r=mo(e,n);if(!r)return null;let s=ho(e,n,r);return Object.assign({},{item:t,score:s,matches:r})},go=(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 fo(u,l,e)},s=t.map(o),i=(u)=>u!==null;return s.filter(i).sort(go)};var Dn=(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})},$n=(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")},Gn=()=>{X.write("\x1B[J")},Wn=()=>{X.write("\x1B[?25l")},Un=()=>{X.write("\x1B[?25h")},Jn=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},zn=()=>{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)},ct=(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,xo=(t,e)=>ct(t,e),bo=(t)=>{let e=`[${t}]`;return f(e,m.dim)},yo=(t)=>f(t,m.gray),Qn=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},So=(t,e,n)=>{let r=Qn(e),o=xo(t.signature,n),s=t.category?bo(t.category):"",i=yo(t.description);return r.concat(" ",o).concat(s?" "+s:"").concat(" - ",i)},wo=(t,e)=>{let{item:n,matches:r}=t,o=Qn(e),s=ct(n.path,r),i=f(`[${n.type}]`,m.dim),c=f(n.displayValue,m.gray);return o.concat(" ",s).concat(" ",i).concat(" ",c)},Eo=(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
37
|
|
|
36
38
|
Building: `,c=f(s,m.bright.concat(m.yellow)),a=`
|
|
37
39
|
|
|
38
40
|
Search methods for `,u=f(t.builder.baseType,m.bright),l=": ",p=t.query;return o.concat(i,c).concat(a,u,l,p,`
|
|
39
41
|
|
|
40
|
-
`)},
|
|
42
|
+
`)},Ao=(t)=>{let e=t.builder!==null,n=t.builder?.arrowFnContext!==null;if(!e||!n)return"";let r="Expression Builder - Arrow Function",o=m.bright.concat(m.cyan),s=f(r,o),i=t.builder.expression,c=`
|
|
41
43
|
|
|
42
44
|
Building: `,a=f(i,m.bright.concat(m.yellow)),u=t.builder.arrowFnContext,l=`
|
|
43
45
|
|
|
44
46
|
Search properties for '${u.paramName}' (${u.paramType}): `,p=t.query;return s.concat(c,a).concat(l,p,`
|
|
45
47
|
|
|
46
|
-
`)},
|
|
47
|
-
`)},To=(t)=>{let e=t.builder===null,n=t.builder?.arrowFnContext===null;if(e||n)return"";let{propertyMatches:r,selectedIndex:o}=t;if(r.length===0)return f("No properties found",m.dim);let s=Math.floor(v/2),i=Math.max(0,o-s),c=Math.min(r.length,i+v);if(c-i<v&&r.length>=v)i=Math.max(0,c-v);let u=r.slice(i,c),l=(h,
|
|
48
|
-
`)},
|
|
48
|
+
`)},No=(t)=>{if(t.builder===null)return"";let{methodMatches:n,selectedIndex:r}=t;if(n.length===0)return f("No methods found",m.dim);let o=Math.floor(v/2),s=Math.max(0,r-o),i=Math.min(n.length,s+v);if(i-s<v&&n.length>=v)s=Math.max(0,i-v);let a=n.slice(s,i),u=(d,h)=>{let N=s+h===r;return So(d.item,N,d.matches)};return a.map(u).join(`
|
|
49
|
+
`)},To=(t)=>{let e=t.builder===null,n=t.builder?.arrowFnContext===null;if(e||n)return"";let{propertyMatches:r,selectedIndex:o}=t;if(r.length===0)return f("No properties found",m.dim);let s=Math.floor(v/2),i=Math.max(0,o-s),c=Math.min(r.length,i+v);if(c-i<v&&r.length>=v)i=Math.max(0,c-v);let u=r.slice(i,c),l=(h,T)=>{let y=i+T===o;return wo(h,y)};return u.map(l).join(`
|
|
50
|
+
`)},Hn=(t)=>{let e=t-v;if(e>0){let r=`
|
|
49
51
|
|
|
50
|
-
... `.concat(String(e)," more");return f(r,m.dim)}return""},
|
|
52
|
+
... `.concat(String(e)," more");return f(r,m.dim)}return""},Kn=()=>{let t=`
|
|
51
53
|
|
|
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)},
|
|
53
|
-
`),r=n.slice(0,
|
|
54
|
+
`.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)},Xn=(t)=>{J();let e=Eo(t);j.write(e);let n=No(t);j.write(n);let r=t.methodMatches.length,o=Hn(r);j.write(o);let s=Kn();j.write(s)},qn=(t)=>{J();let e=Ao(t);j.write(e);let n=To(t);j.write(n);let r=t.propertyMatches.length,o=Hn(r);j.write(o);let s=Kn();j.write(s)};var Yn=x(()=>{Ot()});import{stdout as tr}from"process";var q=10,vt,er=!0,Oo=(t,e)=>ct(t,e),vo=(t)=>{let r="[".concat(t,"]");return f(r,m.dim)},Io=(t)=>f(t,m.gray),Ro=(t)=>{let e=f("\u276F",m.green),n=" ";return t?e:" "},Co=(t,e)=>{let{item:n,matches:r}=t,o=Ro(e),s=Oo(n.path,r),i=vo(n.type),c=Io(n.displayValue);return o.concat(" ",s).concat(" ",i).concat(" ",c)},Fo=()=>{let e=m.bright.concat(m.cyan);return f("1ls Interactive Explorer",e)},Mo,Lo,Zn=5,ko=(t)=>f(String(t),m.cyan),Po=(t)=>{let n=JSON.stringify(t,null,2).split(`
|
|
55
|
+
`),r=n.slice(0,Zn),o=n.length>Zn,s=f(r.join(`
|
|
54
56
|
`),m.cyan);return o?s.concat(f(`
|
|
55
|
-
... (truncated)`,m.dim)):s},
|
|
57
|
+
... (truncated)`,m.dim)):s},_o=(t)=>{let{type:e,displayValue:n,value:r}=t;if(Mo.includes(e))return ko(n);if(Lo.includes(e))return Po(r);return f(String(r),m.cyan)},Bo=(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(`
|
|
56
58
|
|
|
57
59
|
Preview:
|
|
58
|
-
`,m.bright),a=
|
|
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)},
|
|
61
|
-
`):[]},
|
|
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
|
-
`,m.yellow);
|
|
64
|
-
`,m.yellow);
|
|
65
|
-
`)}catch(i){let c=i instanceof Error?i.message:String(i);
|
|
66
|
-
`,m.yellow))}
|
|
60
|
+
`,m.bright),a=_o(i);return c.concat(a)},jo=()=>{let t=`
|
|
61
|
+
|
|
62
|
+
`.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)},Do=(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}},$o=(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}=Do(e,r);return n.slice(s,i).map((a,u)=>{let p=s+u===e;return Co(a,p)})},Vo=(t)=>{let e=t-q;return e>0?["",f("... "+e+" more",m.dim)]:[]},Go=(t)=>{let e=Bo(t);return e?e.split(`
|
|
63
|
+
`):[]},Wo=(t)=>{let e=[Fo(),"","Search: "+t.query,""],n=$o(t),r=Vo(t.matches.length),o=Go(t),s=["",jo().trim()];return[...e,...n,...r,...o,...s]},Uo=(t)=>{J(),tr.write(t.join(`
|
|
64
|
+
`)),vt=t,er=!1},Jo=(t,e)=>{oe(e+1),Vn(),tr.write(t)},zo=(t)=>{if(er){Uo(t);return}if(t.forEach((n,r)=>{if(vt[r]!==n)Jo(n,r)}),t.length<vt.length)oe(t.length+1),Gn();vt=t},Qo=(t)=>{let e=Wo(t);zo(e)},Ho,ie=(t)=>{let e=Ho[t.mode];e(t)};var nr=x(()=>{Ot();Yn();vt=[],Mo=["String","Number","Boolean","null"],Lo=["Array","Object"],Ho={explore:Qo,build:Xn,"build-arrow-fn":qn}});var Ko,Xo,qo,Yo,Y=(t)=>{switch(t){case"Array":return Ko;case"String":return Xo;case"Object":return qo;case"Number":return Yo;default:return[]}};var rr=x(()=>{Ko=[{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"}],Xo=[{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"}],qo=[{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"}],Yo=[{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 sr=(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})},at=(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})},or=(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,T=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",N=i.includes("(a, b)")?"a":"x",y=Tt(h),g={paramName:N,paramType:T,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})},ir=(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})},cr=(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,T,N)=>{let y=h.lastIndexOf(T);if(y===-1)return h;return h.substring(0,y)+N+h.substring(y+T.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})},ar=(t)=>{if(!t.builder)return t;let n=t.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return at(t);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return at(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 ur=x(()=>{rr()});var I,Zo=(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,lr=(t)=>t===I.LEFT,pr=(t)=>t===I.RIGHT,me=(t)=>t===I.BACKSPACE,fe=(t)=>{let e=t>=" ",n=t<="~";return e&&n},ti=(t,e)=>{if(pe(e))return{state:sr(t),output:null};if(le(e)){let n=$n(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}},ei=(t,e)=>{if(e===I.ESCAPE)return{state:at(t),output:null};if(le(e)){if(!t.builder)return{state:t,output:null};return{state:null,output:t.builder.expression}}if(pr(e)||pe(e)){if(!t.builder)return{state:t,output:null};return{state:or(t,t.selectedIndex),output:null}}if(lr(e))return{state:ar(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}},ni=(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(pr(e)||pe(e)){let n=ir(t,t.selectedIndex);return{state:cr(n),output:null}}if(lr(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}},ri,dr=(t,e)=>{let n=e.toString();if(Zo(n)){if(t.mode==="build"||t.mode==="build-arrow-fn")return{state:at(t),output:null};return{state:null,output:null}}let r=ri[t.mode];return r(t,n)};var hr=x(()=>{se();ur();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"}),ri={explore:ti,build:ei,"build-arrow-fn":ni}});var mr={};O(mr,{runInteractive:()=>ci});import{stdin as ge,stdout as ut,exit as lt}from"process";var xe=!1,It=()=>{if(xe)Un(),zn(),xe=!1;J()},be=(t)=>{It();let e=t instanceof Error?t.message:String(t),n=f(`Fatal error: ${e}
|
|
65
|
+
`,m.yellow);ut.write(n),lt(1)},si=()=>{process.on("uncaughtException",be),process.on("unhandledRejection",be),process.on("SIGINT",()=>{It(),lt(0)}),process.on("SIGTERM",()=>{It(),lt(0)})},oi=(t,e)=>{return dr(t,e)},ii=async(t)=>{let e=t;return new Promise((n)=>{let r=(o)=>{let{state:s,output:i}=oi(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)})},ci=async(t)=>{si();let e=Tt(t);if(!(e.length>0)){let o=f(`No paths found in data
|
|
66
|
+
`,m.yellow);ut.write(o),lt(1)}let r=Dn(e,t);Jn(),xe=!0,Wn(),ie(r);try{let o=await ii(r);if(It(),o!==null)try{let i=it(o),a=new et(i).tokenize(),l=new rt(a).parse(),d=new st().evaluate(l,t),h=JSON.stringify(d,null,2);ut.write(h),ut.write(`
|
|
67
|
+
`)}catch(i){let c=i instanceof Error?i.message:String(i);ut.write(f("Error: "+c+`
|
|
68
|
+
`,m.yellow))}lt(0)}catch(o){be(o)}};var fr=x(()=>{se();nr();hr();Ot();zt();Ht();Yt();Et()});var ye=["json","yaml","csv","table"],Se=["json","yaml","toml","csv","tsv","lines","text"],Sr=[{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=Sr.filter((o)=>o.type===t).map((o)=>` ${o.short.padEnd(6)} -> ${o.full.padEnd(14)} ${o.description}`);return`${e}:
|
|
67
69
|
${r.join(`
|
|
68
|
-
`)}`},
|
|
70
|
+
`)}`},hi=`Expression Shortcuts:
|
|
69
71
|
|
|
70
72
|
${Rt("array","Array Methods")}
|
|
71
73
|
|
|
72
74
|
${Rt("object","Object Methods")}
|
|
73
75
|
|
|
74
76
|
${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
|
|
77
|
+
`;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 Ne(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;case"--strict":case"-s":e.strict=!0;break;default:if(r.startsWith(".")||r.startsWith("["))e.expression=r;break}n++}return e}function Ct(){console.log(`
|
|
76
78
|
1ls - 1 line script for JSON manipulation and file operations
|
|
77
79
|
|
|
78
80
|
Usage:
|
|
@@ -120,6 +122,7 @@ Output Options:
|
|
|
120
122
|
-p, --pretty Pretty print JSON
|
|
121
123
|
-c, --compact Compact JSON
|
|
122
124
|
-t, --type Show value type info
|
|
125
|
+
-s, --strict Error on undefined properties
|
|
123
126
|
--format <type> Output format (json|yaml|csv|table)
|
|
124
127
|
-h, --help Show help
|
|
125
128
|
-v, --version Show version
|
|
@@ -145,7 +148,7 @@ Examples:
|
|
|
145
148
|
1ls --shorten ".map(x => x * 2)" # Convert to shorthand
|
|
146
149
|
1ls --expand ".mp(x => x * 2)" # Convert to full form
|
|
147
150
|
1ls --shortcuts # Show all shortcuts
|
|
148
|
-
`)}Wt();Jt();zt();Ht();Yt();var A={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"},
|
|
151
|
+
`)}Wt();Jt();zt();Ht();Yt();var A={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"},ao=[{regex:/"([^"]+)":/g,replacement:`${A.cyan}"$1"${A.reset}:`},{regex:/: "([^"]*)"/g,replacement:`: ${A.green}"$1"${A.reset}`},{regex:/: (-?\d+\.?\d*)/g,replacement:`: ${A.yellow}$1${A.reset}`},{regex:/: (true|false)/g,replacement:`: ${A.magenta}$1${A.reset}`},{regex:/: (null)/g,replacement:`: ${A.gray}$1${A.reset}`},{regex:/([{[])/g,replacement:`${A.gray}$1${A.reset}`},{regex:/([}\]])/g,replacement:`${A.gray}$1${A.reset}`}];function Mn(t){if(process.env.NO_COLOR)return t;return ao.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Ln(t){if(process.env.NO_COLOR)return t;return`${A.yellow}${t}${A.reset}`}function Zt(t){if(process.env.NO_COLOR)return t;return`${A.cyan}${t}${A.reset}`}class ot{options;constructor(t){this.options=t}format(t){if(this.options.raw)return this.formatRaw(t);if(this.options.type)return this.formatWithType(t);switch(this.options.format){case"yaml":return this.formatYaml(t);case"csv":return this.formatCsv(t);case"table":return this.formatTable(t);default:return this.formatJson(t)}}formatRaw(t){if(typeof t==="string")return t;if(t===void 0)return"";if(t===null)return"null";if(typeof t==="object")return JSON.stringify(t);return String(t)}formatJson(t){if(t===void 0)return"undefined";if(this.options.compact)return JSON.stringify(t);if(this.options.pretty){let e=JSON.stringify(t,null,2);return Mn(e)}return JSON.stringify(t,null,2)}formatWithType(t){let e=Array.isArray(t)?"array":typeof t,n=this.formatJson(t);return`[${e}] ${n}`}formatYaml(t){return this.toYaml(t,0)}toYaml(t,e){let n=" ".repeat(e);if(t===null||t===void 0)return"null";if(typeof t==="string")return t.includes(`
|
|
149
152
|
`)||t.includes('"')||t.includes("'")?`|
|
|
150
153
|
${n} ${t.replace(/\n/g,`
|
|
151
154
|
`+n+" ")}`:t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"[]";return t.map((r)=>`${n}- ${this.toYaml(r,e+2).trim()}`).join(`
|
|
@@ -156,4 +159,4 @@ ${i}`;return`${n}${o}: ${i}`}).join(`
|
|
|
156
159
|
`)}escapeCsvValue(t){if(t===null||t===void 0)return"";let e=String(t);if(e.includes(",")||e.includes('"')||e.includes(`
|
|
157
160
|
`))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
161
|
`)}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();
|
|
162
|
+
`)}}Et();bt();var jn="0.1.12";var ai=()=>Promise.resolve().then(() => (fr(),mr));async function ui(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 li(t,e){if(t.readFile){let s=e[e.indexOf("readFile")+1],i=await St(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 gr(t,e){if(!t.expression){let n=new ot(t);console.log(n.format(e));return}try{let n=it(t.expression),o=new et(n).tokenize(),i=new rt(o).parse(),a=new st({strict:t.strict}).evaluate(i,e),u=new ot(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 pi(t){let e=Ne(t);if(e.help)Ct(),process.exit(0);if(e.version)console.log(`1ls version ${jn}`),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(it(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 ot(e).format(r));return}if(e.grep&&e.find){await ui(e);return}if(e.readFile){let r=t[t.indexOf("readFile")+1],o=await St(r),s=t[t.indexOf("readFile")+2]||".",i=s===".";if(e.interactive||i){let{runInteractive:a}=await ai();await a(o);return}e.expression=s,await gr(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 li(e,t);await gr(e,n)}if(import.meta.main)pi(process.argv.slice(2)).catch((t)=>{console.error("Error:",t.message),process.exit(1)});export{gr as processExpression,pi as main,li as loadData,ui as handleGrepOperation,ai as getInteractive};
|
package/dist/navigator/json.d.ts
CHANGED
|
@@ -14,7 +14,12 @@ export declare function sliceArray(arr: unknown, start: number | undefined, end:
|
|
|
14
14
|
export declare function evaluateObjectOperation(obj: unknown, operation: "keys" | "values" | "entries" | "length"): unknown;
|
|
15
15
|
export declare function isCallableMethod(target: unknown, method: string): boolean;
|
|
16
16
|
export declare function callMethod(target: unknown, method: string, args: readonly unknown[]): unknown;
|
|
17
|
+
export interface NavigatorOptions {
|
|
18
|
+
strict?: boolean;
|
|
19
|
+
}
|
|
17
20
|
export declare class JsonNavigator {
|
|
21
|
+
private options;
|
|
22
|
+
constructor(options?: NavigatorOptions);
|
|
18
23
|
evaluate(ast: ASTNode, data: unknown): unknown;
|
|
19
24
|
private evaluatePropertyAccess;
|
|
20
25
|
private evaluateArg;
|
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.12";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "1ls",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "turbo dev --filter=1ls-app",
|
|
31
31
|
"dev:cli": "bun run ./src/cli/index.ts",
|
|
32
|
-
"build": "rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && bun build ./src/browser/index.ts --outdir dist/browser --target browser --minify --format esm && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
|
|
33
|
-
"build:binary:all": "rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
|
|
32
|
+
"build": "bun scripts/sync-version.ts && rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && bun build ./src/browser/index.ts --outdir dist/browser --target browser --minify --format esm && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
|
|
33
|
+
"build:binary:all": "bun scripts/sync-version.ts && rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
|
|
34
34
|
"build:qjs": "bash scripts/build-qjs.sh",
|
|
35
35
|
"build:qjs:bundle": "mkdir -p dist/qjs && bun build ./src/browser/index.ts --outfile dist/qjs/core.js --target browser --minify --format esm",
|
|
36
36
|
"clean": "rm -rf dist bin",
|