@tslite/printer 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var core=require('@tslite/core'),capability=require('@tslite/capability'),sanitize=require('@tslite/sanitize');var C=t=>core.VALID_OBJECT_KEY.test(t);function m(t){let r=n=>{if(typeof n=="string")return `"${n}"`;if(typeof n!="object")return String(n);if(n===null)return "null";if(Array.isArray(n))return `[${n.map(r).join(",")}]`;let s=n;if("#expr"in s){let o=s["#expr"],{"#expr":y,...P}=s,B={type:o,...P};return e(B)}return `{ ${Object.entries(s).map(([o,y])=>`${C(o)?o:`"${o}"`}: ${r(y)}`).join(", ")} }`};return r(t)}var u=", ",l=null,e=t=>{if(t==null)return "";if(Array.isArray(t))return t.filter(Boolean).map(e).join(u);if(typeof t!="object")return String(t);if(!t.type)return JSON.stringify(t);if(t.type in S){if(l){let r=capability.nodeViolation(t,l);if(r)throw new core.TSLiteError("node-not-allowed",`'${r}' is not allowed by the active capability profile.`,{type:t.type})}return S[t.type](t)}throw Error("Unknown type: "+t.type)},L=(t,r)=>{t&&typeof t=="object"&&!Array.isArray(t)&&sanitize.assertSafe(t,r.sanitize==="hermetic"?sanitize.HERMETIC_POLICY:void 0);let n=l;l=capability.compileProfile(r);try{return e(t)}finally{l=n;}},c=t=>`(${t})`;function g(t){if(v.has(t.type))return true;if(t.type!=="Literal")return false;let r=t;return !(typeof r.value=="number"||r.bigint!=null)}var v=new Set(["Identifier","ThisExpression","ArrayExpression","MemberExpression","CallExpression","TemplateLiteral"]),x=t=>{if(t.type==="TSAsExpression")return x(t.expression);let r=e(t);return g(t)?r:c(r)},O=t=>`[${e(t.elements)}]`,J=t=>`[${t.elements.map(n=>n?e(n):"").join(", ")}]`,R=t=>{let r=e(t.params),n=e(t.body),s=t.body.type!=="BlockStatement"&&n.startsWith("{"),i=t.body.type=="AssignmentExpression"||t.body.type=="BinaryExpression"||t.body.type=="ObjectExpression"||t.body.type=="JsonExpression"||s?c(n):n;return `${t.async?"async ":""}(${r}) => ${i}`},W=t=>{let r=e(t.left),n=e(t.right);return `${r} ${t.operator} ${n}`},_=t=>"await "+a(t.argument,core.Precedence.Await,false),$=t=>t.type==="TSAsExpression"?$(t.expression):t,U=t=>{let r=$(t);return r.type==="UnaryExpression"||r.type==="AwaitExpression"},q=(t,r)=>{let n=$(r);if(n.type!=="LogicalExpression")return false;let s=n.operator;return t==="??"?s==="||"||s==="&&":t==="||"||t==="&&"?s==="??":false},V=t=>{let r=core.BinaryPrecedence[t.operator]??1/0,n=t.operator==="**",s=a(t.left,r,false,n),i=n&&(U(t.left)||s[0]==="-"||s[0]==="+")?c(s):s,o=a(t.right,r,true,n);return `${i} ${t.operator} ${o}`},M=t=>{let r=t.body.map(e).filter(n=>n&&n!==";").join("; ");return `{ ${r?r+"; ":""}}`},X=t=>t.label?`break ${e(t.label)}`:"break",z=t=>{let r=x(t.callee),n=t.optional?"?.":"";return `${r}${n}(${e(t.arguments)})`},Y=t=>e(t.expression),h=t=>t.type==="BinaryExpression"||t.type==="LogicalExpression"?core.BinaryPrecedence[t.operator]??1/0:t.type==="ConditionalExpression"?core.Precedence.Conditional:t.type==="AssignmentExpression"?core.Precedence.Assignment:t.type==="ArrowFunctionExpression"?core.Precedence.ArrowFunction:t.type==="AwaitExpression"?core.Precedence.Await:t.type==="SequenceExpression"?core.Precedence.Sequence:t.type==="TSAsExpression"?h(t.expression):1/0,a=(t,r,n,s=false)=>{let i=e(t),o=h(t);return (n?s?o<r:o<=r:s?o<=r:o<r)?c(i):i},K=t=>`${a(t.test,core.Precedence.Conditional,false,true)} ? ${e(t.consequent)} : ${e(t.alternate)}`,H=t=>t.label?`continue ${e(t.label)}`:"continue",G=t=>{let r=e(t.expression);return r[0]==="{"||r.startsWith("function")||r.startsWith("class")?c(r):r},Q=t=>";",Z=t=>`do ${e(t.body)} while (${e(t.test)})`,d=t=>`for (${e(t.left)} in ${e(t.right)}) ${e(t.body)}`,tt=t=>`for${t.await?" await":""} (${e(t.left)} of ${e(t.right)}) ${e(t.body)}`,et=t=>{let r=e(t.init),n=e(t.test),s=e(t.update);return `for (${r};${n?` ${n}`:""};${s?` ${s}`:""}) ${e(t.body)}`},rt=t=>{let r=t.params.map(b).join(u);return `${t.async?"async ":""}function ${e(t.id)}(${r}) ${e(t.body)}`},nt=t=>{let r=e(t.params);return `${t.async?"async ":""}function ${e(t.id)}(${r}) ${e(t.body)}`},b=t=>t.name,st=t=>{throw new core.TSLiteError("incomplete-tree","Cannot print a tree with a Placeholder (hole) \u2014 fill the holes first.",{type:t.type})},ot=t=>`if (${e(t.test)}) ${e(t.consequent)}${t.alternate?` else ${e(t.alternate)}`:""}`,it=t=>m(t.body),pt=t=>t.raw?t.raw:t.value===void 0?"undefined":t.value===null?"null":typeof t.value=="string"?JSON.stringify(t.value):typeof t.value=="boolean"?String(t.value):t.bigint?t.bigint+"n":t.regex?`/${t.regex.pattern}/${t.regex.flags}`:(t.value instanceof RegExp,String(t.value)),at=t=>{let r=core.BinaryPrecedence[t.operator]??1/0,n=(s,i)=>q(t.operator,s)?c(e(s)):a(s,r,i);return `${n(t.left,false)} ${t.operator} ${n(t.right,true)}`},ct=t=>{let r=[x(t.object)];return t.optional&&r.push(t.computed?"?.":"?"),r.push(t.computed?"[":"."),r.push(e(t.property)),t.computed&&r.push("]"),r.join("")},lt=t=>{let r=t.properties.map(e).join(", ");return r.length==0?"{}":`{ ${r} }`},ut=t=>{let r=t.properties.map(e).join(", ");return r.length==0?"{ }":`{ ${r} }`},yt=new Set(["FunctionDeclaration","IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","TryStatement","SwitchStatement","ClassDeclaration"]),mt=t=>t.body.map(r=>{let n=e(r);return n?yt.has(r.type)?n:n+";":""}).filter(Boolean).join(" "),ft=t=>t.shorthand?e(t.value):`${t.computed?`[${e(t.key)}]`:e(t.key)}: ${e(t.value)}`,xt=t=>`${e(t.left)} = ${e(t.right)}`,$t=t=>"return "+e(t.argument),St=t=>(t.test?`case ${e(t.test)}: `:" default: ")+t.consequent.map(e).join("; "),Et=t=>`switch (${e(t.discriminant)}) { ${t.cases.map(e).join("; ")}; }`,Tt=t=>t.value.raw,gt=t=>"`"+t.quasis.map((r,n)=>e(r)+(r.tail?"":"${"+e(t.expressions[n])+"}")).join("")+"`",ht=t=>"throw "+e(t.argument),bt=t=>{let r=`try ${e(t.block)}`;if(t.handler){let n=t.handler.param;r+=n?` catch (${e(n)}) ${e(t.handler.body)}`:` catch ${e(t.handler.body)}`;}return r+(t.finalizer?` finally ${e(t.finalizer)}`:"")},wt=t=>{let r=a(t.argument,core.Precedence.Unary,false),n=t.operator.length>1||(t.operator==="+"||t.operator==="-")&&r[0]===t.operator?" ":"";return t.operator+n+r},At=t=>t.prefix==true?t.operator+e(t.argument):e(t.argument)+t.operator,It=t=>`${t.kind} ${t.declarations.map(w).join(", ")}`,w=t=>t.init?`${e(t.id)} = ${e(t.init)}`:e(t.id),Pt=t=>`while (${e(t.test)}) ${e(t.body)}`,Bt=t=>{let r=e(t.source);return t.specifiers.length==0?`import ${r}`:t.specifiers[0].type=="ImportNamespaceSpecifier"?`import ${e(t.specifiers[0])} from ${r}`:t.specifiers[0].type=="ImportDefaultSpecifier"?`import ${e(t.specifiers[0])} from ${r}`:`import { ${t.specifiers.filter(s=>s.type==="ImportSpecifier").map(A).join(u)} } from ${r}`},jt=t=>e(t.local),Ct=t=>`* as ${e(t.local)}`,A=t=>t.imported.name===t.local.name?`${e(t.local)}`:`${e(t.imported)} as ${e(t.local)}`,Nt=t=>t.declaration?`export ${e(t.declaration)}`:`export { ${t.specifiers.map(I).join(u)} }`,Dt=t=>`export default ${e(t.declaration)}`,I=t=>t.local.name===t.exported.name?`${e(t.local)}`:`${e(t.local)} as ${e(t.exported)}`,Ft=t=>`...${e(t.argument)}`,kt=t=>`...${e(t.argument)}`,Lt=()=>"",vt=t=>e(t.expression),Ot=t=>e(core.desugarJSX(t)),Jt=t=>e(core.desugarJSX(t)),S={print:e,JSXElement:Ot,JSXFragment:Jt,ArrayExpression:O,ArrayPattern:J,ArrowFunctionExpression:R,AssignmentExpression:W,AssignmentPattern:xt,AwaitExpression:_,BinaryExpression:V,BlockStatement:M,BreakStatement:X,CallExpression:z,ChainExpression:Y,ConditionalExpression:K,ContinueStatement:H,DoWhileStatement:Z,EmptyStatement:Q,ExpressionStatement:G,ForInStatement:d,ForOfStatement:tt,ForStatement:et,FunctionDeclaration:rt,FunctionExpression:nt,Identifier:b,Placeholder:st,IfStatement:ot,ImportDeclaration:Bt,ImportDefaultSpecifier:jt,ImportNamespaceSpecifier:Ct,ImportSpecifier:A,ExportNamedDeclaration:Nt,ExportDefaultDeclaration:Dt,ExportSpecifier:I,JsonExpression:it,Literal:pt,LogicalExpression:at,MemberExpression:ct,ObjectExpression:lt,ObjectPattern:ut,Program:mt,Property:ft,ReturnStatement:$t,SwitchCase:St,SwitchStatement:Et,TemplateElement:Tt,TemplateLiteral:gt,ThrowStatement:ht,TryStatement:bt,UnaryExpression:wt,UpdateExpression:At,VariableDeclaration:It,VariableDeclarator:w,WhileStatement:Pt,SpreadElement:Ft,RestElement:kt,TSTypeAliasDeclaration:Lt,TSAsExpression:vt};exports.isPrimaryOperand=g;exports.print=e;exports.printJson=m;exports.printWithProfile=L;
1
+ 'use strict';var core=require('@tslite/core'),capability=require('@tslite/capability'),sanitize=require('@tslite/sanitize');var F=t=>core.VALID_OBJECT_KEY.test(t);function y(t){let e=n=>{if(typeof n=="string")return `"${n}"`;if(typeof n!="object")return String(n);if(n===null)return "null";if(Array.isArray(n))return `[${n.map(e).join(",")}]`;let s=n;if("#expr"in s){let i=s["#expr"],{"#expr":E,...N}=s,D={type:i,...N};return r(D)}return `{ ${Object.entries(s).map(([i,E])=>`${F(i)?i:`"${i}"`}: ${e(E)}`).join(", ")} }`};return e(t)}var u=", ",l=null,r=t=>{if(t==null)return "";if(Array.isArray(t))return t.filter(Boolean).map(r).join(u);if(typeof t!="object")return String(t);if(!t.type)return JSON.stringify(t);if(t.type in T){if(l){let e=capability.nodeViolation(t,l);if(e)throw new core.TSLiteError("node-not-allowed",`'${e}' is not allowed by the active capability profile.`,{type:t.type})}return T[t.type](t)}throw Error("Unknown type: "+t.type)},R=(t,e)=>{t&&typeof t=="object"&&!Array.isArray(t)&&sanitize.assertSafe(t,e.sanitize==="hermetic"?sanitize.HERMETIC_POLICY:void 0);let n=l;l=capability.compileProfile(e);try{return r(t)}finally{l=n;}},c=t=>`(${t})`;function b(t){if(W.has(t.type))return true;if(t.type!=="Literal")return false;let e=t;return !(typeof e.value=="number"||e.bigint!=null)}var W=new Set(["Identifier","ThisExpression","ArrayExpression","MemberExpression","CallExpression","TemplateLiteral"]),f=t=>{if(t.type==="TSAsExpression")return f(t.expression);let e=r(t);return b(t)?e:c(e)},_=t=>`[${r(t.elements)}]`,U=t=>`[${t.elements.map(n=>n?r(n):"").join(", ")}]`,q=t=>{let e=r(t.params),n=r(t.body),s=t.body.type!=="BlockStatement"&&n.startsWith("{"),o=t.body.type=="AssignmentExpression"||t.body.type=="BinaryExpression"||t.body.type=="ObjectExpression"||t.body.type=="JsonExpression"||s?c(n):n;return `${t.async?"async ":""}(${e}) => ${o}`},V=t=>{let e=r(t.left),n=r(t.right);return `${e} ${t.operator} ${n}`},M=t=>"await "+p(t.argument,core.Precedence.Await,false),x=t=>t.type==="TSAsExpression"?x(t.expression):t,w=t=>{let e=x(t);return e.type==="UnaryExpression"||e.type==="AwaitExpression"},A=(t,e)=>{let n=x(e);if(n.type!=="LogicalExpression")return false;let s=n.operator;return t==="??"?s==="||"||s==="&&":t==="||"||t==="&&"?s==="??":false},X=t=>{let e=core.BinaryPrecedence[t.operator]??1/0,n=t.operator==="**",s=p(t.left,e,false,n),o=n&&(w(t.left)||s[0]==="-"||s[0]==="+")?c(s):s,i=p(t.right,e,true,n);return `${o} ${t.operator} ${i}`},K=t=>{let e=t.body.map(S).filter(Boolean).join(" ");return `{ ${e?e+" ":""}}`},z=t=>t.label?`break ${r(t.label)}`:"break",Y=t=>{let e=f(t.callee),n=t.optional?"?.":"";return `${e}${n}(${r(t.arguments)})`},H=t=>r(t.expression),$=t=>t.type==="BinaryExpression"||t.type==="LogicalExpression"?core.BinaryPrecedence[t.operator]??1/0:t.type==="ConditionalExpression"?core.Precedence.Conditional:t.type==="AssignmentExpression"?core.Precedence.Assignment:t.type==="ArrowFunctionExpression"?core.Precedence.ArrowFunction:t.type==="AwaitExpression"?core.Precedence.Await:t.type==="SequenceExpression"?core.Precedence.Sequence:t.type==="TSAsExpression"?$(t.expression):1/0,B=(t,e,n,s=false)=>{let o=$(t);return n?s?o<e:o<=e:s?o<=e:o<e},p=(t,e,n,s=false)=>{let o=r(t);return B(t,e,n,s)?c(o):o},G=t=>`${p(t.test,core.Precedence.Conditional,false,true)} ? ${r(t.consequent)} : ${r(t.alternate)}`,Q=t=>t.label?`continue ${r(t.label)}`:"continue",Z=t=>{let e=r(t.expression);return e[0]==="{"||e.startsWith("function")||e.startsWith("class")?c(e):e},d=t=>";",tt=t=>`do ${r(t.body)} while (${r(t.test)})`,et=t=>`for (${r(t.left)} in ${r(t.right)}) ${r(t.body)}`,rt=t=>`for${t.await?" await":""} (${r(t.left)} of ${r(t.right)}) ${r(t.body)}`,nt=t=>{let e=r(t.init),n=r(t.test),s=r(t.update);return `for (${e};${n?` ${n}`:""};${s?` ${s}`:""}) ${r(t.body)}`},st=t=>{let e=t.params.map(P).join(u);return `${t.async?"async ":""}function ${r(t.id)}(${e}) ${r(t.body)}`},ot=t=>{let e=r(t.params);return `${t.async?"async ":""}function ${r(t.id)}(${e}) ${r(t.body)}`},P=t=>t.name,it=t=>{throw new core.TSLiteError("incomplete-tree","Cannot print a tree with a Placeholder (hole) \u2014 fill the holes first.",{type:t.type})},at=t=>`if (${r(t.test)}) ${r(t.consequent)}${t.alternate?` else ${r(t.alternate)}`:""}`,pt=t=>y(t.body),ct=t=>t.raw?t.raw:t.value===void 0?"undefined":t.value===null?"null":typeof t.value=="string"?JSON.stringify(t.value):typeof t.value=="boolean"?String(t.value):t.bigint?t.bigint+"n":t.regex?`/${t.regex.pattern}/${t.regex.flags}`:(t.value instanceof RegExp,String(t.value)),lt=t=>{let e=core.BinaryPrecedence[t.operator]??1/0,n=(s,o)=>A(t.operator,s)?c(r(s)):p(s,e,o);return `${n(t.left,false)} ${t.operator} ${n(t.right,true)}`},ut=t=>{let e=[f(t.object)];return t.optional&&e.push(t.computed?"?.":"?"),e.push(t.computed?"[":"."),e.push(r(t.property)),t.computed&&e.push("]"),e.join("")},yt=t=>{let e=t.properties.map(r).join(", ");return e.length==0?"{}":`{ ${e} }`},mt=t=>{let e=t.properties.map(r).join(", ");return e.length==0?"{ }":`{ ${e} }`},ft=new Set(["FunctionDeclaration","IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","TryStatement","SwitchStatement","ClassDeclaration","BlockStatement"]),S=t=>{let e=r(t);return !e||e===";"?"":ft.has(t.type)?e:e+";"},xt=t=>t.body.map(S).filter(Boolean).join(" "),$t=t=>t.shorthand?r(t.value):`${t.computed?`[${r(t.key)}]`:r(t.key)}: ${r(t.value)}`,St=t=>`${r(t.left)} = ${r(t.right)}`,Et=t=>"return "+r(t.argument),Tt=t=>{let e=t.test?`case ${r(t.test)}:`:"default:",n=t.consequent.map(S).filter(Boolean).join(" ");return n?`${e} ${n}`:e},gt=t=>`switch (${r(t.discriminant)}) { ${t.cases.map(r).join(" ")} }`,ht=t=>t.value.raw,bt=t=>"`"+t.quasis.map((e,n)=>r(e)+(e.tail?"":"${"+r(t.expressions[n])+"}")).join("")+"`",wt=t=>"throw "+r(t.argument),At=t=>{let e=`try ${r(t.block)}`;if(t.handler){let n=t.handler.param;e+=n?` catch (${r(n)}) ${r(t.handler.body)}`:` catch ${r(t.handler.body)}`;}return e+(t.finalizer?` finally ${r(t.finalizer)}`:"")},Bt=t=>{let e=p(t.argument,core.Precedence.Unary,false),n=t.operator.length>1||(t.operator==="+"||t.operator==="-")&&e[0]===t.operator?" ":"";return t.operator+n+e},Pt=t=>t.prefix==true?t.operator+r(t.argument):r(t.argument)+t.operator,It=t=>`${t.kind} ${t.declarations.map(I).join(", ")}`,I=t=>t.init?`${r(t.id)} = ${r(t.init)}`:r(t.id),jt=t=>`while (${r(t.test)}) ${r(t.body)}`,Ct=t=>{if(t.importKind==="type")return "";let e=r(t.source);if(t.specifiers.length==0)return `import ${e}`;let n=t.specifiers.find(i=>i.type==="ImportDefaultSpecifier"||i.type==="ImportNamespaceSpecifier"),s=t.specifiers.filter(i=>i.type==="ImportSpecifier"&&i.importKind!=="type");if(!n&&s.length===0)return "";let o=[];return n&&o.push(r(n)),s.length&&o.push(`{ ${s.map(j).join(u)} }`),`import ${o.join(u)} from ${e}`},Nt=t=>r(t.local),Dt=t=>`* as ${r(t.local)}`,j=t=>t.imported.name===t.local.name?`${r(t.local)}`:`${r(t.imported)} as ${r(t.local)}`,kt=t=>{if(t.declaration){let n=r(t.declaration);return n?`export ${n}`:""}return `export { ${t.specifiers.map(C).join(u)} }`},Ft=t=>`export default ${r(t.declaration)}`,C=t=>t.local.name===t.exported.name?`${r(t.local)}`:`${r(t.local)} as ${r(t.exported)}`,Lt=t=>`...${r(t.argument)}`,vt=t=>`...${r(t.argument)}`,Ot=()=>"",Jt=t=>r(t.expression),Rt=t=>r(core.desugarJSX(t)),Wt=t=>r(core.desugarJSX(t)),T={print:r,JSXElement:Rt,JSXFragment:Wt,ArrayExpression:_,ArrayPattern:U,ArrowFunctionExpression:q,AssignmentExpression:V,AssignmentPattern:St,AwaitExpression:M,BinaryExpression:X,BlockStatement:K,BreakStatement:z,CallExpression:Y,ChainExpression:H,ConditionalExpression:G,ContinueStatement:Q,DoWhileStatement:tt,EmptyStatement:d,ExpressionStatement:Z,ForInStatement:et,ForOfStatement:rt,ForStatement:nt,FunctionDeclaration:st,FunctionExpression:ot,Identifier:P,Placeholder:it,IfStatement:at,ImportDeclaration:Ct,ImportDefaultSpecifier:Nt,ImportNamespaceSpecifier:Dt,ImportSpecifier:j,ExportNamedDeclaration:kt,ExportDefaultDeclaration:Ft,ExportSpecifier:C,JsonExpression:pt,Literal:ct,LogicalExpression:lt,MemberExpression:ut,ObjectExpression:yt,ObjectPattern:mt,Program:xt,Property:$t,ReturnStatement:Et,SwitchCase:Tt,SwitchStatement:gt,TemplateElement:ht,TemplateLiteral:bt,ThrowStatement:wt,TryStatement:At,UnaryExpression:Bt,UpdateExpression:Pt,VariableDeclaration:It,VariableDeclarator:I,WhileStatement:jt,SpreadElement:Lt,RestElement:vt,TSTypeAliasDeclaration:Ot,TSAsExpression:Jt};exports.getExpressionPrecedence=$;exports.isPrimaryOperand=b;exports.mixesCoalesce=A;exports.needsParens=B;exports.print=r;exports.printJson=y;exports.printWithProfile=R;exports.unaryLike=w;
package/dist/index.d.cts CHANGED
@@ -20,6 +20,33 @@ declare const printWithProfile: (ast: PrintInput, profile: CapabilityProfile) =>
20
20
  * promessa da plataforma é ser um subset PURO de TS.
21
21
  */
22
22
  declare function isPrimaryOperand(node: BaseNode): boolean;
23
+ /** Operando que começa com unário/`await` (à esquerda de `**` exige parênteses). */
24
+ declare const unaryLike: (node: BaseNode) => boolean;
25
+ declare const mixesCoalesce: (parentOp: string, child: BaseNode) => boolean;
26
+ /**
27
+ * Returns the operator precedence of an expression node.
28
+ * Higher value = binds tighter. Returns Infinity for atoms (Identifier, Literal, etc).
29
+ */
30
+ /** A precedência efetiva de uma expressão (erasure de `as`); `Infinity` = primária. */
31
+ declare const getExpressionPrecedence: (node: BaseNode) => number;
32
+ /**
33
+ * Wraps a child node in parentheses when its precedence is lower than
34
+ * the parent's, respecting left/right associativity rules.
35
+ *
36
+ * For left-associative operators (most):
37
+ * - left child: parens when childPrec < parentPrec
38
+ * - right child: parens when childPrec <= parentPrec
39
+ *
40
+ * For right-associative operators (**):
41
+ * - left child: parens when childPrec <= parentPrec
42
+ * - right child: parens when childPrec < parentPrec
43
+ */
44
+ /**
45
+ * A DECISÃO de parentizar um operando pela precedência — exportada para quem
46
+ * imprime por outra via (o `@tslite/emit` renderiza `Doc`, não texto) tomar a
47
+ * mesma decisão, em vez de manter uma segunda máquina de precedência.
48
+ */
49
+ declare const needsParens: (node: BaseNode, parentPrec: number, isRight: boolean, rightAssociative?: boolean) => boolean;
23
50
 
24
51
  /**
25
52
  * Prints the hybrid JSON form (a value with `#expr` islands) as JS source.
@@ -34,4 +61,4 @@ declare function isPrimaryOperand(node: BaseNode): boolean;
34
61
  */
35
62
  declare function printJson(node: TSLite): string;
36
63
 
37
- export { isPrimaryOperand, print, printJson, printWithProfile };
64
+ export { getExpressionPrecedence, isPrimaryOperand, mixesCoalesce, needsParens, print, printJson, printWithProfile, unaryLike };
package/dist/index.d.ts CHANGED
@@ -20,6 +20,33 @@ declare const printWithProfile: (ast: PrintInput, profile: CapabilityProfile) =>
20
20
  * promessa da plataforma é ser um subset PURO de TS.
21
21
  */
22
22
  declare function isPrimaryOperand(node: BaseNode): boolean;
23
+ /** Operando que começa com unário/`await` (à esquerda de `**` exige parênteses). */
24
+ declare const unaryLike: (node: BaseNode) => boolean;
25
+ declare const mixesCoalesce: (parentOp: string, child: BaseNode) => boolean;
26
+ /**
27
+ * Returns the operator precedence of an expression node.
28
+ * Higher value = binds tighter. Returns Infinity for atoms (Identifier, Literal, etc).
29
+ */
30
+ /** A precedência efetiva de uma expressão (erasure de `as`); `Infinity` = primária. */
31
+ declare const getExpressionPrecedence: (node: BaseNode) => number;
32
+ /**
33
+ * Wraps a child node in parentheses when its precedence is lower than
34
+ * the parent's, respecting left/right associativity rules.
35
+ *
36
+ * For left-associative operators (most):
37
+ * - left child: parens when childPrec < parentPrec
38
+ * - right child: parens when childPrec <= parentPrec
39
+ *
40
+ * For right-associative operators (**):
41
+ * - left child: parens when childPrec <= parentPrec
42
+ * - right child: parens when childPrec < parentPrec
43
+ */
44
+ /**
45
+ * A DECISÃO de parentizar um operando pela precedência — exportada para quem
46
+ * imprime por outra via (o `@tslite/emit` renderiza `Doc`, não texto) tomar a
47
+ * mesma decisão, em vez de manter uma segunda máquina de precedência.
48
+ */
49
+ declare const needsParens: (node: BaseNode, parentPrec: number, isRight: boolean, rightAssociative?: boolean) => boolean;
23
50
 
24
51
  /**
25
52
  * Prints the hybrid JSON form (a value with `#expr` islands) as JS source.
@@ -34,4 +61,4 @@ declare function isPrimaryOperand(node: BaseNode): boolean;
34
61
  */
35
62
  declare function printJson(node: TSLite): string;
36
63
 
37
- export { isPrimaryOperand, print, printJson, printWithProfile };
64
+ export { getExpressionPrecedence, isPrimaryOperand, mixesCoalesce, needsParens, print, printJson, printWithProfile, unaryLike };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {Precedence,BinaryPrecedence,TSLiteError,desugarJSX,VALID_OBJECT_KEY}from'@tslite/core';import {compileProfile,nodeViolation}from'@tslite/capability';import {assertSafe,HERMETIC_POLICY}from'@tslite/sanitize';var C=t=>VALID_OBJECT_KEY.test(t);function m(t){let r=n=>{if(typeof n=="string")return `"${n}"`;if(typeof n!="object")return String(n);if(n===null)return "null";if(Array.isArray(n))return `[${n.map(r).join(",")}]`;let s=n;if("#expr"in s){let o=s["#expr"],{"#expr":y,...P}=s,B={type:o,...P};return e(B)}return `{ ${Object.entries(s).map(([o,y])=>`${C(o)?o:`"${o}"`}: ${r(y)}`).join(", ")} }`};return r(t)}var u=", ",l=null,e=t=>{if(t==null)return "";if(Array.isArray(t))return t.filter(Boolean).map(e).join(u);if(typeof t!="object")return String(t);if(!t.type)return JSON.stringify(t);if(t.type in S){if(l){let r=nodeViolation(t,l);if(r)throw new TSLiteError("node-not-allowed",`'${r}' is not allowed by the active capability profile.`,{type:t.type})}return S[t.type](t)}throw Error("Unknown type: "+t.type)},L=(t,r)=>{t&&typeof t=="object"&&!Array.isArray(t)&&assertSafe(t,r.sanitize==="hermetic"?HERMETIC_POLICY:void 0);let n=l;l=compileProfile(r);try{return e(t)}finally{l=n;}},c=t=>`(${t})`;function g(t){if(v.has(t.type))return true;if(t.type!=="Literal")return false;let r=t;return !(typeof r.value=="number"||r.bigint!=null)}var v=new Set(["Identifier","ThisExpression","ArrayExpression","MemberExpression","CallExpression","TemplateLiteral"]),x=t=>{if(t.type==="TSAsExpression")return x(t.expression);let r=e(t);return g(t)?r:c(r)},O=t=>`[${e(t.elements)}]`,J=t=>`[${t.elements.map(n=>n?e(n):"").join(", ")}]`,R=t=>{let r=e(t.params),n=e(t.body),s=t.body.type!=="BlockStatement"&&n.startsWith("{"),i=t.body.type=="AssignmentExpression"||t.body.type=="BinaryExpression"||t.body.type=="ObjectExpression"||t.body.type=="JsonExpression"||s?c(n):n;return `${t.async?"async ":""}(${r}) => ${i}`},W=t=>{let r=e(t.left),n=e(t.right);return `${r} ${t.operator} ${n}`},_=t=>"await "+a(t.argument,Precedence.Await,false),$=t=>t.type==="TSAsExpression"?$(t.expression):t,U=t=>{let r=$(t);return r.type==="UnaryExpression"||r.type==="AwaitExpression"},q=(t,r)=>{let n=$(r);if(n.type!=="LogicalExpression")return false;let s=n.operator;return t==="??"?s==="||"||s==="&&":t==="||"||t==="&&"?s==="??":false},V=t=>{let r=BinaryPrecedence[t.operator]??1/0,n=t.operator==="**",s=a(t.left,r,false,n),i=n&&(U(t.left)||s[0]==="-"||s[0]==="+")?c(s):s,o=a(t.right,r,true,n);return `${i} ${t.operator} ${o}`},M=t=>{let r=t.body.map(e).filter(n=>n&&n!==";").join("; ");return `{ ${r?r+"; ":""}}`},X=t=>t.label?`break ${e(t.label)}`:"break",z=t=>{let r=x(t.callee),n=t.optional?"?.":"";return `${r}${n}(${e(t.arguments)})`},Y=t=>e(t.expression),h=t=>t.type==="BinaryExpression"||t.type==="LogicalExpression"?BinaryPrecedence[t.operator]??1/0:t.type==="ConditionalExpression"?Precedence.Conditional:t.type==="AssignmentExpression"?Precedence.Assignment:t.type==="ArrowFunctionExpression"?Precedence.ArrowFunction:t.type==="AwaitExpression"?Precedence.Await:t.type==="SequenceExpression"?Precedence.Sequence:t.type==="TSAsExpression"?h(t.expression):1/0,a=(t,r,n,s=false)=>{let i=e(t),o=h(t);return (n?s?o<r:o<=r:s?o<=r:o<r)?c(i):i},K=t=>`${a(t.test,Precedence.Conditional,false,true)} ? ${e(t.consequent)} : ${e(t.alternate)}`,H=t=>t.label?`continue ${e(t.label)}`:"continue",G=t=>{let r=e(t.expression);return r[0]==="{"||r.startsWith("function")||r.startsWith("class")?c(r):r},Q=t=>";",Z=t=>`do ${e(t.body)} while (${e(t.test)})`,d=t=>`for (${e(t.left)} in ${e(t.right)}) ${e(t.body)}`,tt=t=>`for${t.await?" await":""} (${e(t.left)} of ${e(t.right)}) ${e(t.body)}`,et=t=>{let r=e(t.init),n=e(t.test),s=e(t.update);return `for (${r};${n?` ${n}`:""};${s?` ${s}`:""}) ${e(t.body)}`},rt=t=>{let r=t.params.map(b).join(u);return `${t.async?"async ":""}function ${e(t.id)}(${r}) ${e(t.body)}`},nt=t=>{let r=e(t.params);return `${t.async?"async ":""}function ${e(t.id)}(${r}) ${e(t.body)}`},b=t=>t.name,st=t=>{throw new TSLiteError("incomplete-tree","Cannot print a tree with a Placeholder (hole) \u2014 fill the holes first.",{type:t.type})},ot=t=>`if (${e(t.test)}) ${e(t.consequent)}${t.alternate?` else ${e(t.alternate)}`:""}`,it=t=>m(t.body),pt=t=>t.raw?t.raw:t.value===void 0?"undefined":t.value===null?"null":typeof t.value=="string"?JSON.stringify(t.value):typeof t.value=="boolean"?String(t.value):t.bigint?t.bigint+"n":t.regex?`/${t.regex.pattern}/${t.regex.flags}`:(t.value instanceof RegExp,String(t.value)),at=t=>{let r=BinaryPrecedence[t.operator]??1/0,n=(s,i)=>q(t.operator,s)?c(e(s)):a(s,r,i);return `${n(t.left,false)} ${t.operator} ${n(t.right,true)}`},ct=t=>{let r=[x(t.object)];return t.optional&&r.push(t.computed?"?.":"?"),r.push(t.computed?"[":"."),r.push(e(t.property)),t.computed&&r.push("]"),r.join("")},lt=t=>{let r=t.properties.map(e).join(", ");return r.length==0?"{}":`{ ${r} }`},ut=t=>{let r=t.properties.map(e).join(", ");return r.length==0?"{ }":`{ ${r} }`},yt=new Set(["FunctionDeclaration","IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","TryStatement","SwitchStatement","ClassDeclaration"]),mt=t=>t.body.map(r=>{let n=e(r);return n?yt.has(r.type)?n:n+";":""}).filter(Boolean).join(" "),ft=t=>t.shorthand?e(t.value):`${t.computed?`[${e(t.key)}]`:e(t.key)}: ${e(t.value)}`,xt=t=>`${e(t.left)} = ${e(t.right)}`,$t=t=>"return "+e(t.argument),St=t=>(t.test?`case ${e(t.test)}: `:" default: ")+t.consequent.map(e).join("; "),Et=t=>`switch (${e(t.discriminant)}) { ${t.cases.map(e).join("; ")}; }`,Tt=t=>t.value.raw,gt=t=>"`"+t.quasis.map((r,n)=>e(r)+(r.tail?"":"${"+e(t.expressions[n])+"}")).join("")+"`",ht=t=>"throw "+e(t.argument),bt=t=>{let r=`try ${e(t.block)}`;if(t.handler){let n=t.handler.param;r+=n?` catch (${e(n)}) ${e(t.handler.body)}`:` catch ${e(t.handler.body)}`;}return r+(t.finalizer?` finally ${e(t.finalizer)}`:"")},wt=t=>{let r=a(t.argument,Precedence.Unary,false),n=t.operator.length>1||(t.operator==="+"||t.operator==="-")&&r[0]===t.operator?" ":"";return t.operator+n+r},At=t=>t.prefix==true?t.operator+e(t.argument):e(t.argument)+t.operator,It=t=>`${t.kind} ${t.declarations.map(w).join(", ")}`,w=t=>t.init?`${e(t.id)} = ${e(t.init)}`:e(t.id),Pt=t=>`while (${e(t.test)}) ${e(t.body)}`,Bt=t=>{let r=e(t.source);return t.specifiers.length==0?`import ${r}`:t.specifiers[0].type=="ImportNamespaceSpecifier"?`import ${e(t.specifiers[0])} from ${r}`:t.specifiers[0].type=="ImportDefaultSpecifier"?`import ${e(t.specifiers[0])} from ${r}`:`import { ${t.specifiers.filter(s=>s.type==="ImportSpecifier").map(A).join(u)} } from ${r}`},jt=t=>e(t.local),Ct=t=>`* as ${e(t.local)}`,A=t=>t.imported.name===t.local.name?`${e(t.local)}`:`${e(t.imported)} as ${e(t.local)}`,Nt=t=>t.declaration?`export ${e(t.declaration)}`:`export { ${t.specifiers.map(I).join(u)} }`,Dt=t=>`export default ${e(t.declaration)}`,I=t=>t.local.name===t.exported.name?`${e(t.local)}`:`${e(t.local)} as ${e(t.exported)}`,Ft=t=>`...${e(t.argument)}`,kt=t=>`...${e(t.argument)}`,Lt=()=>"",vt=t=>e(t.expression),Ot=t=>e(desugarJSX(t)),Jt=t=>e(desugarJSX(t)),S={print:e,JSXElement:Ot,JSXFragment:Jt,ArrayExpression:O,ArrayPattern:J,ArrowFunctionExpression:R,AssignmentExpression:W,AssignmentPattern:xt,AwaitExpression:_,BinaryExpression:V,BlockStatement:M,BreakStatement:X,CallExpression:z,ChainExpression:Y,ConditionalExpression:K,ContinueStatement:H,DoWhileStatement:Z,EmptyStatement:Q,ExpressionStatement:G,ForInStatement:d,ForOfStatement:tt,ForStatement:et,FunctionDeclaration:rt,FunctionExpression:nt,Identifier:b,Placeholder:st,IfStatement:ot,ImportDeclaration:Bt,ImportDefaultSpecifier:jt,ImportNamespaceSpecifier:Ct,ImportSpecifier:A,ExportNamedDeclaration:Nt,ExportDefaultDeclaration:Dt,ExportSpecifier:I,JsonExpression:it,Literal:pt,LogicalExpression:at,MemberExpression:ct,ObjectExpression:lt,ObjectPattern:ut,Program:mt,Property:ft,ReturnStatement:$t,SwitchCase:St,SwitchStatement:Et,TemplateElement:Tt,TemplateLiteral:gt,ThrowStatement:ht,TryStatement:bt,UnaryExpression:wt,UpdateExpression:At,VariableDeclaration:It,VariableDeclarator:w,WhileStatement:Pt,SpreadElement:Ft,RestElement:kt,TSTypeAliasDeclaration:Lt,TSAsExpression:vt};export{g as isPrimaryOperand,e as print,m as printJson,L as printWithProfile};
1
+ import {BinaryPrecedence,Precedence,TSLiteError,desugarJSX,VALID_OBJECT_KEY}from'@tslite/core';import {compileProfile,nodeViolation}from'@tslite/capability';import {assertSafe,HERMETIC_POLICY}from'@tslite/sanitize';var F=t=>VALID_OBJECT_KEY.test(t);function y(t){let e=n=>{if(typeof n=="string")return `"${n}"`;if(typeof n!="object")return String(n);if(n===null)return "null";if(Array.isArray(n))return `[${n.map(e).join(",")}]`;let s=n;if("#expr"in s){let i=s["#expr"],{"#expr":E,...N}=s,D={type:i,...N};return r(D)}return `{ ${Object.entries(s).map(([i,E])=>`${F(i)?i:`"${i}"`}: ${e(E)}`).join(", ")} }`};return e(t)}var u=", ",l=null,r=t=>{if(t==null)return "";if(Array.isArray(t))return t.filter(Boolean).map(r).join(u);if(typeof t!="object")return String(t);if(!t.type)return JSON.stringify(t);if(t.type in T){if(l){let e=nodeViolation(t,l);if(e)throw new TSLiteError("node-not-allowed",`'${e}' is not allowed by the active capability profile.`,{type:t.type})}return T[t.type](t)}throw Error("Unknown type: "+t.type)},R=(t,e)=>{t&&typeof t=="object"&&!Array.isArray(t)&&assertSafe(t,e.sanitize==="hermetic"?HERMETIC_POLICY:void 0);let n=l;l=compileProfile(e);try{return r(t)}finally{l=n;}},c=t=>`(${t})`;function b(t){if(W.has(t.type))return true;if(t.type!=="Literal")return false;let e=t;return !(typeof e.value=="number"||e.bigint!=null)}var W=new Set(["Identifier","ThisExpression","ArrayExpression","MemberExpression","CallExpression","TemplateLiteral"]),f=t=>{if(t.type==="TSAsExpression")return f(t.expression);let e=r(t);return b(t)?e:c(e)},_=t=>`[${r(t.elements)}]`,U=t=>`[${t.elements.map(n=>n?r(n):"").join(", ")}]`,q=t=>{let e=r(t.params),n=r(t.body),s=t.body.type!=="BlockStatement"&&n.startsWith("{"),o=t.body.type=="AssignmentExpression"||t.body.type=="BinaryExpression"||t.body.type=="ObjectExpression"||t.body.type=="JsonExpression"||s?c(n):n;return `${t.async?"async ":""}(${e}) => ${o}`},V=t=>{let e=r(t.left),n=r(t.right);return `${e} ${t.operator} ${n}`},M=t=>"await "+p(t.argument,Precedence.Await,false),x=t=>t.type==="TSAsExpression"?x(t.expression):t,w=t=>{let e=x(t);return e.type==="UnaryExpression"||e.type==="AwaitExpression"},A=(t,e)=>{let n=x(e);if(n.type!=="LogicalExpression")return false;let s=n.operator;return t==="??"?s==="||"||s==="&&":t==="||"||t==="&&"?s==="??":false},X=t=>{let e=BinaryPrecedence[t.operator]??1/0,n=t.operator==="**",s=p(t.left,e,false,n),o=n&&(w(t.left)||s[0]==="-"||s[0]==="+")?c(s):s,i=p(t.right,e,true,n);return `${o} ${t.operator} ${i}`},K=t=>{let e=t.body.map(S).filter(Boolean).join(" ");return `{ ${e?e+" ":""}}`},z=t=>t.label?`break ${r(t.label)}`:"break",Y=t=>{let e=f(t.callee),n=t.optional?"?.":"";return `${e}${n}(${r(t.arguments)})`},H=t=>r(t.expression),$=t=>t.type==="BinaryExpression"||t.type==="LogicalExpression"?BinaryPrecedence[t.operator]??1/0:t.type==="ConditionalExpression"?Precedence.Conditional:t.type==="AssignmentExpression"?Precedence.Assignment:t.type==="ArrowFunctionExpression"?Precedence.ArrowFunction:t.type==="AwaitExpression"?Precedence.Await:t.type==="SequenceExpression"?Precedence.Sequence:t.type==="TSAsExpression"?$(t.expression):1/0,B=(t,e,n,s=false)=>{let o=$(t);return n?s?o<e:o<=e:s?o<=e:o<e},p=(t,e,n,s=false)=>{let o=r(t);return B(t,e,n,s)?c(o):o},G=t=>`${p(t.test,Precedence.Conditional,false,true)} ? ${r(t.consequent)} : ${r(t.alternate)}`,Q=t=>t.label?`continue ${r(t.label)}`:"continue",Z=t=>{let e=r(t.expression);return e[0]==="{"||e.startsWith("function")||e.startsWith("class")?c(e):e},d=t=>";",tt=t=>`do ${r(t.body)} while (${r(t.test)})`,et=t=>`for (${r(t.left)} in ${r(t.right)}) ${r(t.body)}`,rt=t=>`for${t.await?" await":""} (${r(t.left)} of ${r(t.right)}) ${r(t.body)}`,nt=t=>{let e=r(t.init),n=r(t.test),s=r(t.update);return `for (${e};${n?` ${n}`:""};${s?` ${s}`:""}) ${r(t.body)}`},st=t=>{let e=t.params.map(P).join(u);return `${t.async?"async ":""}function ${r(t.id)}(${e}) ${r(t.body)}`},ot=t=>{let e=r(t.params);return `${t.async?"async ":""}function ${r(t.id)}(${e}) ${r(t.body)}`},P=t=>t.name,it=t=>{throw new TSLiteError("incomplete-tree","Cannot print a tree with a Placeholder (hole) \u2014 fill the holes first.",{type:t.type})},at=t=>`if (${r(t.test)}) ${r(t.consequent)}${t.alternate?` else ${r(t.alternate)}`:""}`,pt=t=>y(t.body),ct=t=>t.raw?t.raw:t.value===void 0?"undefined":t.value===null?"null":typeof t.value=="string"?JSON.stringify(t.value):typeof t.value=="boolean"?String(t.value):t.bigint?t.bigint+"n":t.regex?`/${t.regex.pattern}/${t.regex.flags}`:(t.value instanceof RegExp,String(t.value)),lt=t=>{let e=BinaryPrecedence[t.operator]??1/0,n=(s,o)=>A(t.operator,s)?c(r(s)):p(s,e,o);return `${n(t.left,false)} ${t.operator} ${n(t.right,true)}`},ut=t=>{let e=[f(t.object)];return t.optional&&e.push(t.computed?"?.":"?"),e.push(t.computed?"[":"."),e.push(r(t.property)),t.computed&&e.push("]"),e.join("")},yt=t=>{let e=t.properties.map(r).join(", ");return e.length==0?"{}":`{ ${e} }`},mt=t=>{let e=t.properties.map(r).join(", ");return e.length==0?"{ }":`{ ${e} }`},ft=new Set(["FunctionDeclaration","IfStatement","ForStatement","ForInStatement","ForOfStatement","WhileStatement","TryStatement","SwitchStatement","ClassDeclaration","BlockStatement"]),S=t=>{let e=r(t);return !e||e===";"?"":ft.has(t.type)?e:e+";"},xt=t=>t.body.map(S).filter(Boolean).join(" "),$t=t=>t.shorthand?r(t.value):`${t.computed?`[${r(t.key)}]`:r(t.key)}: ${r(t.value)}`,St=t=>`${r(t.left)} = ${r(t.right)}`,Et=t=>"return "+r(t.argument),Tt=t=>{let e=t.test?`case ${r(t.test)}:`:"default:",n=t.consequent.map(S).filter(Boolean).join(" ");return n?`${e} ${n}`:e},gt=t=>`switch (${r(t.discriminant)}) { ${t.cases.map(r).join(" ")} }`,ht=t=>t.value.raw,bt=t=>"`"+t.quasis.map((e,n)=>r(e)+(e.tail?"":"${"+r(t.expressions[n])+"}")).join("")+"`",wt=t=>"throw "+r(t.argument),At=t=>{let e=`try ${r(t.block)}`;if(t.handler){let n=t.handler.param;e+=n?` catch (${r(n)}) ${r(t.handler.body)}`:` catch ${r(t.handler.body)}`;}return e+(t.finalizer?` finally ${r(t.finalizer)}`:"")},Bt=t=>{let e=p(t.argument,Precedence.Unary,false),n=t.operator.length>1||(t.operator==="+"||t.operator==="-")&&e[0]===t.operator?" ":"";return t.operator+n+e},Pt=t=>t.prefix==true?t.operator+r(t.argument):r(t.argument)+t.operator,It=t=>`${t.kind} ${t.declarations.map(I).join(", ")}`,I=t=>t.init?`${r(t.id)} = ${r(t.init)}`:r(t.id),jt=t=>`while (${r(t.test)}) ${r(t.body)}`,Ct=t=>{if(t.importKind==="type")return "";let e=r(t.source);if(t.specifiers.length==0)return `import ${e}`;let n=t.specifiers.find(i=>i.type==="ImportDefaultSpecifier"||i.type==="ImportNamespaceSpecifier"),s=t.specifiers.filter(i=>i.type==="ImportSpecifier"&&i.importKind!=="type");if(!n&&s.length===0)return "";let o=[];return n&&o.push(r(n)),s.length&&o.push(`{ ${s.map(j).join(u)} }`),`import ${o.join(u)} from ${e}`},Nt=t=>r(t.local),Dt=t=>`* as ${r(t.local)}`,j=t=>t.imported.name===t.local.name?`${r(t.local)}`:`${r(t.imported)} as ${r(t.local)}`,kt=t=>{if(t.declaration){let n=r(t.declaration);return n?`export ${n}`:""}return `export { ${t.specifiers.map(C).join(u)} }`},Ft=t=>`export default ${r(t.declaration)}`,C=t=>t.local.name===t.exported.name?`${r(t.local)}`:`${r(t.local)} as ${r(t.exported)}`,Lt=t=>`...${r(t.argument)}`,vt=t=>`...${r(t.argument)}`,Ot=()=>"",Jt=t=>r(t.expression),Rt=t=>r(desugarJSX(t)),Wt=t=>r(desugarJSX(t)),T={print:r,JSXElement:Rt,JSXFragment:Wt,ArrayExpression:_,ArrayPattern:U,ArrowFunctionExpression:q,AssignmentExpression:V,AssignmentPattern:St,AwaitExpression:M,BinaryExpression:X,BlockStatement:K,BreakStatement:z,CallExpression:Y,ChainExpression:H,ConditionalExpression:G,ContinueStatement:Q,DoWhileStatement:tt,EmptyStatement:d,ExpressionStatement:Z,ForInStatement:et,ForOfStatement:rt,ForStatement:nt,FunctionDeclaration:st,FunctionExpression:ot,Identifier:P,Placeholder:it,IfStatement:at,ImportDeclaration:Ct,ImportDefaultSpecifier:Nt,ImportNamespaceSpecifier:Dt,ImportSpecifier:j,ExportNamedDeclaration:kt,ExportDefaultDeclaration:Ft,ExportSpecifier:C,JsonExpression:pt,Literal:ct,LogicalExpression:lt,MemberExpression:ut,ObjectExpression:yt,ObjectPattern:mt,Program:xt,Property:$t,ReturnStatement:Et,SwitchCase:Tt,SwitchStatement:gt,TemplateElement:ht,TemplateLiteral:bt,ThrowStatement:wt,TryStatement:At,UnaryExpression:Bt,UpdateExpression:Pt,VariableDeclaration:It,VariableDeclarator:I,WhileStatement:jt,SpreadElement:Lt,RestElement:vt,TSTypeAliasDeclaration:Ot,TSAsExpression:Jt};export{$ as getExpressionPrecedence,b as isPrimaryOperand,A as mixesCoalesce,B as needsParens,r as print,y as printJson,R as printWithProfile,w as unaryLike};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tslite/printer",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "TSLite printer — emits JavaScript source from an AST (and from the hybrid #expr JSON form)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -40,9 +40,9 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@tslite/capability": "0.4.0",
44
- "@tslite/core": "0.8.0",
45
- "@tslite/sanitize": "0.1.7"
43
+ "@tslite/capability": "0.4.1",
44
+ "@tslite/core": "0.8.2",
45
+ "@tslite/sanitize": "0.1.9"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup",