Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error on Babel? #117

Closed
Anooxy17 opened this issue Sep 23, 2024 · 34 comments · Fixed by #133
Closed

Syntax Error on Babel? #117

Anooxy17 opened this issue Sep 23, 2024 · 34 comments · Fixed by #133

Comments

@Anooxy17
Copy link

image

file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14
`);return t.length>1&&t.every(e=>e.trimStart()[0]==="*")}var wt=wr;function Cr(a){return ge(a)&&a.value[0]==="*"&&/@(?:type|satisfies)\b/u.test(a.value)}var xs=Cr;var Te=null;function be(a){if(Te!==null&&typeof Te.property){let t=Te;return Te=be.prototype=null,t}return Te=be.prototype=a??Object.create(null),new be}var Er=10;for(let a=0;a<=Er;a++)be();function Ct(a){return be(a)}function Ir(a,t="type"){Ct(a);function e(s){let i=s[t],r=a[i];if(!Array.isArray(r))throw Object.assign(new Error(`Missing visitor keys for '${i}'.`),{node:s});return r}return e}var Ps=Ir;var gs={ArrayExpression:["elements"],AssignmentExpression:["left","right"],BinaryExpression:["left","right"],InterpreterDirective:[],Directive:["value"],DirectiveLiteral:[],BlockStatement:["directives","body"],BreakStatement:["label"],CallExpression:["callee","arguments","typeParameters","typeArguments"],CatchClause:["param","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DoWhileStatement:["test","body"],EmptyStatement:[],ExpressionStatement:["expression"],File:["program"],ForInStatement:["left","right","body"],ForStatement:["init","test","update","body"],FunctionDeclaration:["id","params","body","returnType","typeParameters","predicate"],FunctionExpression:["id","params","body","returnType","typeParameters"],Identifier:["typeAnnotation","decorators"],IfStatement:["test","consequent","alternate"],LabeledStatement:["label","body"],StringLiteral:[],NumericLiteral:[],NullLiteral:[],BooleanLiteral:[],RegExpLiteral:[],LogicalExpression:["left","right"],MemberExpression:["object","property"],NewExpression:["callee","arguments","typeParameters","typeArguments"],Program:["directives","body"],ObjectExpression:["properties"],ObjectMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectProperty:["key","value","decorators"],RestElement:["argument","typeAnnotation","decorators"],ReturnStatement:["argument"],SequenceExpression:["expressions"],ParenthesizedExpression:["expression"],SwitchCase:["test","consequent"],SwitchStatement:["discriminant","cases"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],AssignmentPattern:["left","right","decorators","typeAnnotation"],ArrayPattern:["elements","typeAnnotation","decorators"],ArrowFunctionExpression:["params","body","returnType","typeParameters","predicate"],ClassBody:["body"],ClassExpression:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ClassDeclaration:["id","body","superClass","mixins","typeParameters","superTypeParameters","implements","decorators","superTypeArguments"],ExportAllDeclaration:["source","attributes","exported"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source","attributes"],ExportSpecifier:["local","exported"],ForOfStatement:["left","right","body"],ImportDeclaration:["specifiers","source","attributes"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["local","imported"],ImportExpression:["source","options","attributes"],MetaProperty:["meta","property"],ClassMethod:["key","params","body","decorators","returnType","typeParameters"],ObjectPattern:["properties","typeAnnotation","decorators"],SpreadElement:["argument"],Super:[],TaggedTemplateExpression:["tag","quasi","typeParameters","typeArguments"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],YieldExpression:["argument"],AwaitExpression:["argument"],Import:[],BigIntLiteral:[],ExportNamespaceSpecifier:["exported"],OptionalMemberExpression:["object","property"],OptionalCallExpression:["callee","arguments","typeParameters","typeArguments"],ClassProperty:["key","value","typeAnnotation","decorators","variance"],ClassAccessorProperty:["key","value","typeAnnotation","decorators"],ClassPrivateProperty:["key","value","decorators","typeAnnotation","variance"],ClassPrivateMethod:["key","params","body","decorators","returnType","typeParameters"],PrivateName:["id"],StaticBlock:["body"],AnyTypeAnnotation:[],ArrayTypeAnnotation:["elementType"],BooleanTypeAnnotation:[],BooleanLiteralTypeAnnotation:[],NullLiteralTypeAnnotation:[],ClassImplements:["id","typeParameters"],DeclareClass:["id","typeParameters","extends","mixins","implements","body"],DeclareFunction:["id","predicate"],DeclareInterface:["id","typeParameters","extends","body"],DeclareModule:["id","body"],DeclareModuleExports:["typeAnnotation"],DeclareTypeAlias:["id","typeParameters","right"],DeclareOpaqueType:["id","typeParameters","supertype"],DeclareVariable:["id"],DeclareExportDeclaration:["declaration","specifiers","source"],DeclareExportAllDeclaration:["source"],DeclaredPredicate:["value"],ExistsTypeAnnotation:[],FunctionTypeAnnotation:["typeParameters","params","rest","returnType","this"],FunctionTypeParam:["name","typeAnnotation"],GenericTypeAnnotation:["id","typeParameters"],InferredPredicate:[],InterfaceExtends:["id","typeParameters"],InterfaceDeclaration:["id","typeParameters","extends","body"],InterfaceTypeAnnotation:["extends","body"],IntersectionTypeAnnotation:["types"],MixedTypeAnnotation:[],EmptyTypeAnnotation:[],NullableTypeAnnotation:["typeAnnotation"],NumberLiteralTypeAnnotation:[],NumberTypeAnnotation:[],ObjectTypeAnnotation:["properties","indexers","callProperties","internalSlots"],ObjectTypeInternalSlot:["id","value"],ObjectTypeCallProperty:["value"],ObjectTypeIndexer:["id","key","value","variance"],ObjectTypeProperty:["key","value","variance"],ObjectTypeSpreadProperty:["argument"],OpaqueType:["id","typeParameters","supertype","impltype"],QualifiedTypeIdentifier:["id","qualification"],StringLiteralTypeAnnotation:[],StringTypeAnnotation:[],SymbolTypeAnnotation:[],ThisTypeAnnotation:[],TupleTypeAnnotation:["types","elementTypes"],TypeofTypeAnnotation:["argument","typeArguments"],TypeAlias:["id","typeParameters","right"],TypeAnnotation:["typeAnnotation"],TypeCastExpression:["expression","typeAnnotation"],TypeParameter:["bound","default","variance"],TypeParameterDeclaration:["params"],TypeParameterInstantiation:["params"],UnionTypeAnnotation:["types"],Variance:[],VoidTypeAnnotation:[],EnumDeclaration:["id","body"],EnumBooleanBody:["members"],EnumNumberBody:["members"],EnumStringBody:["members"],EnumSymbolBody:["members"],EnumBooleanMember:["id","init"],EnumNumberMember:["id","init"],EnumStringMember:["id","init"],EnumDefaultedMember:["id"],IndexedAccessType:["objectType","indexType"],OptionalIndexedAccessType:["objectType","indexType"],JSXAttribute:["name","value"],JSXClosingElement:["name"],JSXElement:["openingElement","children","closingElement"],JSXEmptyExpression:[],JSXExpressionContainer:["expression"],JSXSpreadChild:["expression"],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"],JSXOpeningElement:["name","attributes","typeArguments","typeParameters"],JSXSpreadAttribute:["argument"],JSXText:[],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningFragment:[],JSXClosingFragment:[],Noop:[],Placeholder:[],V8IntrinsicIdentifier:[],ArgumentPlaceholder:[],BindExpression:["object","callee"],ImportAttribute:["key","value"],Decorator:["expression"],DoExpression:["body"],ExportDefaultSpecifier:["exported"],RecordExpression:["properties"],TupleExpression:["elements"],DecimalLiteral:[],ModuleExpression:["body"],TopicReference:[],PipelineTopicExpression:["expression"],PipelineBareFunction:["callee"],PipelinePrimaryTopicReference:[],TSParameterProperty:["parameter","decorators"],TSDeclareFunction:["id","typeParameters","params","returnType","body"],TSDeclareMethod:["decorators","key","typeParameters","params","returnType"],TSQualifiedName:["left","right"],TSCallSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructSignatureDeclaration:["typeParameters","parameters","typeAnnotation","params","returnType"],TSPropertySignature:["key","typeAnnotation"],TSMethodSignature:["key","typeParameters","parameters","typeAnnotation","params","returnType"],TSIndexSignature:["parameters","typeAnnotation"],TSAnyKeyword:[],TSBooleanKeyword:[],TSBigIntKeyword:[],TSIntrinsicKeyword:[],TSNeverKeyword:[],TSNullKeyword:[],TSNumberKeyword:[],TSObjectKeyword:[],TSStringKeyword:[],TSSymbolKeyword:[],TSUndefinedKeyword:[],TSUnknownKeyword:[],TSVoidKeyword:[],TSThisType:[],TSFunctionType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSConstructorType:["typeParameters","parameters","typeAnnotation","params","returnType"],TSTypeReference:["typeName","typeParameters","typeArguments"],TSTypePredicate:["parameterName","typeAnnotation"],TSTypeQuery:["exprName","typeParameters","typeArguments"],TSTypeLiteral:["members"],TSArrayType:["elementType"],TSTupleType:["elementTypes"],TSOptionalType:["typeAnnotation"],TSRestType:["typeAnnotation"],TSNamedTupleMember:["label","elementType"],TSUnionType:["types"],TSIntersectionType:["types"],TSConditionalType:["checkType","extendsType","trueType","falseType"],TSInferType:["typeParameter"],TSParenthesizedType:["typeAnnotation"],TSTypeOperator:["typeAnnotation"],TSIndexedAccessType:["objectType","indexType"],TSMappedType:["typeParameter","typeAnnotation","nameType"],TSLiteralType:["literal"],TSExpressionWithTypeArguments:["expression","typeParameters"],TSInterfaceDeclaration:["id","typeParameters","extends","body"],TSInterfaceBody:["body"],TSTypeAliasDeclaration:["id","typeParameters","typeAnnotation"],TSInstantiationExpression:["expression","typeParameters","typeArguments"],TSAsExpression:["expression","typeAnnotation"],TSSatisfiesExpression:["expression","typeAnnotation"],TSTypeAssertion:["typeAnnotation","expression"],TSEnumDeclaration:["id","members"],TSEnumMember:["id","initializer"],TSModuleDeclaration:["id","body"],TSModuleBlock:["body"],TSImportType:["argument","qualifier","typeParameters","typeArguments"],TSImportEqualsDeclaration:["id","moduleReference"],TSExternalModuleReference:["expression"],TSNonNullExpression:["expression"],TSExportAssignment:["expression"],TSNamespaceExportDeclaration:["id"],TSTypeAnnotation:["typeAnnotation"],TSTypeParameterInstantiation:["params"],TSTypeParameterDeclaration:["params"],TSTypeParameter:["constraint","default","name"],ChainExpression:["expression"],ExperimentalRestProperty:["argument"],ExperimentalSpreadProperty:["argument"],Literal:[],MethodDefinition:["decorators","key","value"],PrivateIdentifier:[],Property:["key","value"],PropertyDefinition:["decorators","key","typeAnnotation","value","variance"],AccessorProperty:["decorators","key","typeAnnotation","value"],TSAbstractAccessorProperty:["decorators","key","typeAnnotation"],TSAbstractKeyword:[],TSAbstractMethodDefinition:["key","value"],TSAbstractPropertyDefinition:["decorators","key","typeAnnotation"],TSAsyncKeyword:[],TSClassImplements:["expression","typeArguments","typeParameters"],TSDeclareKeyword:[],TSEmptyBodyFunctionExpression:["id","typeParameters","params","returnType"],TSEnumBody:["members"],TSExportKeyword:[],TSInterfaceHeritage:["expression","typeArguments","typeParameters"],TSPrivateKeyword:[],TSProtectedKeyword:[],TSPublicKeyword:[],TSReadonlyKeyword:[],TSStaticKeyword:[],TSTemplateLiteralType:["quasis","types"],AsConstExpression:["expression"],AsExpression:["expression","typeAnnotation"],BigIntLiteralTypeAnnotation:[],BigIntTypeAnnotation:[],ComponentDeclaration:["id","params","body","typeParameters","rendersType"],ComponentParameter:["name","local"],ComponentTypeAnnotation:["params","rest","typeParameters","rendersType"],ComponentTypeParameter:["name","typeAnnotation"],ConditionalTypeAnnotation:["checkType","extendsType","trueType","falseType"],DeclareComponent:["id","params","rest","typeParameters","rendersType"],DeclareEnum:["id","body"],DeclareHook:["id"],DeclareNamespace:["id","body"],EnumBigIntBody:["members"],EnumBigIntMember:["id","init"],HookDeclaration:["id","params","body","typeParameters","returnType"],HookTypeAnnotation:["params","returnType","rest","typeParameters"],InferTypeAnnotation:["typeParameter"],KeyofTypeAnnotation:["argument"],ObjectTypeMappedTypeProperty:["keyTparam","propType","sourceType","variance"],QualifiedTypeofIdentifier:["qualification","id"],TupleTypeLabeledElement:["label","elementType","variance"],TupleTypeSpreadElement:["label","typeAnnotation"],TypeOperator:["typeAnnotation"],TypePredicate:["parameterName","typeAnnotation","asserts"],NGRoot:["node"],NGPipeExpression:["left","right","arguments"],NGChainedExpression:["expressions"],NGEmptyExpression:[],NGMicrosyntax:["body"],NGMicrosyntaxKey:[],NGMicrosyntaxExpression:["expression","alias"],NGMicrosyntaxKeyedExpression:["key","expression"],NGMicrosyntaxLet:["key","value"],NGMicrosyntaxAs:["key","alias"],JsExpressionRoot:["node"],JsonRoot:["node"],TSJSDocAllType:[],TSJSDocUnknownType:[],TSJSDocNullableType:["typeAnnotation"],TSJSDocNonNullableType:["typeAnnotation"],NeverTypeAnnotation:[],UndefinedTypeAnnotation:[],UnknownTypeAnnotation:[],SatisfiesExpression:["expression","typeAnnotation"]};var Nr=Ps(gs),Ts=Nr;function Et(a,t){if(!(a!==null&&typeof a=="object"))return a;if(Array.isArray(a)){for(let s=0;s<a.length;s++)a[s]=Et(a[s],t);return a}let e=Ts(a);for(let s=0;s<e.length;s++)a[e[s]]=Et(a[e[s]],t);return t(a)||a}var Fe=Et;function kr(a,t){let{parser:e,text:s}=t;if(a.type==="File"&&a.program.interpreter){let{program:{interpreter:i},comments:r}=a;delete a.program.interpreter,r.unshift(i);}if(e==="babel"){let i=new Set;a=Fe(a,r=>{var n;(n=r.leadingComments)!=null&&n.some(xs)&&i.add(D(r));}),a=Fe(a,r=>{if(r.type==="ParenthesizedExpression"){let{expression:n}=r;if(n.type==="TypeCastExpression")return n.range=[...r.range],n;let o=D(r);if(!i.has(o))return n.extra={...n.extra,parenthesized:!0},n}});}if(a=Fe(a,i=>{var r;switch(i.type){case"LogicalExpression":if(bs(i))return It(i);break;case"VariableDeclaration":{let n=St(!1,i.declarations,-1);n!=null&&n.init&&s[B(n)]!==";"&&(i.range=[D(i),B(n)]);break}case"TSParenthesizedType":return i.typeAnnotation;case"TSTypeParameter":if(typeof i.name=="string"){let n=D(i);i.name={type:"Identifier",name:i.name,range:[n,n+i.name.length]};}break;case"TopicReference":a.extra={...a.extra,__isUsingHackPipeline:!0};break;case"ExportAllDeclaration":if(e==="meriyah"&&((r=i.exported)==null?void 0:r.type)==="Identifier"){let{exported:n}=i,o=s.slice(D(n),B(n));(o.startsWith('"')||o.startsWith("'"))&&(i.exported={...i.exported,type:"Literal",value:i.exported.name,raw:o});}break;case"TSUnionType":case"TSIntersectionType":if(i.types.length===1)return i.types[0];break}}),Pe(a.comments)){let i=St(!1,a.comments,-1);for(let r=a.comments.length-2;r>=0;r--){let n=a.comments[r];B(n)===D(i)&&ge(n)&&ge(i)&&wt(n)&&wt(i)&&(a.comments.splice(r+1,1),n.value+="*//*"+i.value,n.range=[D(n),B(i)]),i=n;}}return a.type==="Program"&&(a.range=[0,s.length]),a}function bs(a){return a.type==="LogicalExpression"&&a.right.type==="LogicalExpression"&&a.operator===a.right.operator}function It(a){return bs(a)?It({type:"LogicalExpression",operator:a.operator,left:It({type:"LogicalExpression",operator:a.operator,left:a.left,right:a.right.left,range:[D(a.left),B(a.right.left)]}),right:a.right.right,range:[D(a),B(a)]}):a}var As=kr;function vr(a,t){let e=new SyntaxError(a+" ("+t.loc.start.line+":"+t.loc.start.column+")");return Object.assign(e,t)}var Be=vr;function Lr(a){let{message:t,loc:{line:e,column:s},reasonCode:i}=a,r=a;(i==="MissingPlugin"||i==="MissingOneOfPlugins")&&(t="Unexpected token.",r=void 0);let n=` (${e}:${s})`;return t.endsWith(n)&&(t=t.slice(0,-n.length)),Be(t,{loc:{start:{line:e,column:s+1}},cause:r})}var Re=Lr;var Dr=(a,t,e,s)=>{if(!(a&&t==null))return t.replaceAll?t.replaceAll(e,s):e.global?t.replace(e,s):t.split(e).join(s)},ie=Dr;var Mr=/\*\/$/,Or=/^\/\*\*?/,Fr=/^\s*(\/\*\*?(.|\r?\n)*?\*\/)/,Br=/(^|\s+)\/\/([^\n\r]*)/g,Ss=/^(\r?\n)+/,Rr=/(?:^|\r?\n) *(@[^\n\r]*?) *\r?\n *(?![^\n\r@]*\/\/[^]*)([^\s@][^\n\r@]+?) *\r?\n/g,ws=/(?:^|\r?\n) *@(\S+) *([^\n\r]*)/g,Ur=/(\r?\n|^) *\* ?/g,_r=[];function Cs(a){let t=a.match(Fr);return t?t[0].trimStart():""}function Es(a){let t=`





SyntaxError: Unexpected token, expected "," (1327:23)
  1325 |       return dataPointDetails;
  1326 |     }
> 1327 |     static Qp(_static calculateQualityParameter, qualityParameter) {
       |                       ^
  1328 |       let qualityCalculator = new InvestmentBalance();
  1329 |       var qualityParameterValue = _UtilityClass.J(_static calculateQualityParameter.d0, getPeWithEmptyStringUtil);
  1330 |       var qualityData = _UtilityClass.J(_static calculateQualityParameter.d1, getPeWithEmptyStringUtil);
    at vr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15472)
    at Lr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15798)
    at Object.parse (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:15:2885)
    at parse4 (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:21890:24)
    at async coreFormat (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:22343:7)
    at async formatWithCursor (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:22545:14)
    at async Object.format2 (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:23920:25)
    at async unminify (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:202:27)
    at async Command.<anonymous> (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56797:3) {
  loc: { start: { line: 1327, column: 23 } },
  cause: SyntaxError: Unexpected token, expected "," (1327:22)
      at s (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:3:11485)
      at De.raise (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:5:19392)
      at De.unexpected (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:5:19754)
      at De.expect (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:5:24308)
      at De.parseBindingList (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:11470)
      at De.parseFunctionParams (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:31272)
      at De.parseMethod (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:4732)
      at De.pushClassMethod (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:36905)
      at De.parseClassMemberWithIsStatic (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:34345)
      at De.parseClassMember (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:33374)
      at file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:32547
      at De.withSmartMixTopicForbiddingContext (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:11378)
      at De.parseClassBody (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:32223)
      at De.parseClass (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:31668)
      at De.parseStatementContent (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:17039)
      at De.parseStatementLike (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:16403)
      at De.parseStatementListItem (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:16040)
      at De.parseBlockOrModuleBlockBody (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:28122)
      at De.parseBlockBody (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:27942)
      at De.parseBlock (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:27663)
      at De.parseFunctionBody (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:6109)
      at De.parseFunctionBodyAndFinish (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:5776)
      at file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:30909
      at De.withSmartMixTopicForbiddingContext (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:11378)
      at De.parseFunction (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:30864)
      at De.parseFunctionOrFunctionSent (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:96871)
      at De.parseExprAtom (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:92532)
      at De.parseExprAtom (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:5336)
      at De.parseExprSubscripts (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86862)
      at De.parseUpdate (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86489)
      at De.parseMaybeUnary (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86123)
      at De.parseMaybeUnaryOrPrivate (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:83079)
      at De.parseExprOps (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:83177)
      at De.parseMaybeConditional (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:82683)
      at De.parseMaybeAssign (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81947)
      at file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81526
      at De.allowInAnd (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:8:11654)
      at De.parseMaybeAssignAllowIn (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81506)
      at De.parseParenAndDistinguishExpression (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:99364)
      at De.parseExprAtom (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:92238)
      at De.parseExprAtom (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:5336)
      at De.parseExprSubscripts (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86862)
      at De.parseUpdate (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86489)
      at De.parseMaybeUnary (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:86123)
      at De.parseMaybeUnaryOrPrivate (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:83079)
      at De.parseExprOps (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:83177)
      at De.parseMaybeConditional (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:82683)
      at De.parseMaybeAssign (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81947)
      at De.parseExpressionBase (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81136)
      at file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:7:81056 {
    code: 'BABEL_PARSER_SYNTAX_ERROR',
    reasonCode: 'UnexpectedToken',
    loc: F { line: 1327, column: 22, index: 52743 },
    pos: 52743
  },
  codeFrame: '\x1B[0m \x1B[90m 1325 |\x1B[39m       \x1B[36mreturn\x1B[39m dataPointDetails\x1B[33m;\x1B[39m\n' +
    ' \x1B[90m 1326 |\x1B[39m     }\n' +
    '\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 1327 |\x1B[39m     \x1B[36mstatic\x1B[39m \x1B[33mQp\x1B[39m(_static calculateQualityParameter\x1B[33m,\x1B[39m qualityParameter) {\n' +
    ' \x1B[90m      |\x1B[39m                       \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\n' +
    ' \x1B[90m 1328 |\x1B[39m       \x1B[36mlet\x1B[39m qualityCalculator \x1B[33m=\x1B[39m \x1B[36mnew\x1B[39m \x1B[33mInvestmentBalance\x1B[39m()\x1B[33m;\x1B[39m\n' +
    ' \x1B[90m 1329 |\x1B[39m       \x1B[36mvar\x1B[39m qualityParameterValue \x1B[33m=\x1B[39m _UtilityClass\x1B[33m.\x1B[39m\x1B[33mJ\x1B[39m(_static calculateQualityParameter\x1B[33m.\x1B[39md0\x1B[33m,\x1B[39m getPeWithEmptyStringUtil)\x1B[33m;\x1B[39m\n' +
    ' \x1B[90m 1330 |\x1B[39m       \x1B[36mvar\x1B[39m qualityData \x1B[33m=\x1B[39m _UtilityClass\x1B[33m.\x1B[39m\x1B[33mJ\x1B[39m(_static calculateQualityParameter\x1B[33m.\x1B[39md1\x1B[33m,\x1B[39m getPeWithEmptyStringUtil)\x1B[33m;\x1B[39m\x1B[0m'
}

Node.js v20.5.0

obfuscated.txt

It's on OPENAI. Cant decode this file in OpenAI, cant on Gemini, local etc, nothing :(

@Yusufkulcu
Copy link

I have the same problem, but no clear solution has been found

@jehna
Copy link
Owner

jehna commented Sep 25, 2024

Thank you for the detailed issue! I'll look into it. It seems that this line is indeed missing a ,:

static Qp(_static calculateQualityParameter, qualityParameter) {

Tha does seem super strange to me, as there should definitely not be a space there. I'll have a look at it a bit later.

@Yusufkulcu
Copy link

Thank you for the detailed issue! I'll look into it. It seems that this line is indeed missing a ,:

static Qp(_static calculateQualityParameter, qualityParameter) {

Tha does seem super strange to me, as there should definitely not be a space there. I'll have a look at it a bit later.

If you have time, could you also look at my problem, I would be very grateful
#111

@0xdevalias
Copy link

It seems that this line is indeed missing a ,:

@jehna @Anooxy17 Looking at the attached obfuscated.txt, on what appears to be that same lines of code:

# ..snip..

        static Qp(a, b) {
            let c = new ib;
            var d = w.J(a.d0, Ob)
              , e = w.J(a.d1, Ob);
            let f = a.color
              , g = a.strength;

# ..snip..

It looks like the problem is less that there should be a ,, and more that that something is adding the _static prefix to the variable where it presumably shouldn't be.

I can see that a lot of the function names have a static prefix; not sure if that ended up confusing the LLM when it was trying to come up with useful param renames or similar; but that is where I would start looking.

I wonder if running it again with --verbose or similar would provide better info for debugging this further? May help narrow down where/why the _static prefix is being introduced to things?

Another theory is that the _ is being prefixed onto static to avoid it clashing with a JS keyword. I still don't know that it should be present for this param at all in general though.

@0xdevalias
Copy link

0xdevalias commented Sep 26, 2024

I have the same problem, but no clear solution has been found

@Yusufkulcu Your problem in #111 (which is a duplicate of #54) isn't the same as the problem in this issue.

If you have time, could you also look at my problem, I would be very grateful

@Yusufkulcu Spamming other issues trying to draw more attention to an issue you raised is generally considered rude and bad practice in open-source.

@0xdevalias
Copy link

0xdevalias commented Sep 26, 2024

Looking at the attached obfuscated.txt, on what appears to be that same lines of code:

# ..snip..

        static Qp(a, b) {
            let c = new ib;
            var d = w.J(a.d0, Ob)
              , e = w.J(a.d1, Ob);
            let f = a.color
              , g = a.strength;

# ..snip..

I tried running this locally with the --verbose flag. I didn't let it complete, but I did let it get past the above Qp code, without running into any errors:

..snip..

[2024-09-26 03:46:49]  Processing: 5%
[2024-09-26 03:46:49]  Renaming a
[2024-09-26 03:46:49]  Context:  static Qp(a, b) {
  let c = new ib();
  var d = w.J(a.d0, Ob);
  var e = w.J(a.d1, Ob);
  let f = a.color;
  let g = a.strength;
  a = a.length;
  if (d >= b.length || d < 0) {
    throw v.C(null);
  
[2024-09-26 03:46:49]  Renamed to qpInstance
[2024-09-26 03:46:49]  Processing: 5%
[2024-09-26 03:46:50]  Renaming b
[2024-09-26 03:46:50]  Context:  static Qp(qpInstance, b) {
  let c = new ib();
  var d = w.J(qpInstance.d0, Ob);
  var e = w.J(qpInstance.d1, Ob);
  let f = qpInstance.color;
  let g = qpInstance.strength;
  qpInstance = qpInstance.
[2024-09-26 03:46:50]  Renamed to strengthValue
[2024-09-26 03:46:50]  Processing: 5%
[2024-09-26 03:46:50]  Renaming c
[2024-09-26 03:46:50]  Context:  static Qp(qpInstance, strengthValue) {
  let c = new ib();
  var d = w.J(qpInstance.d0, Ob);
  var e = w.J(qpInstance.d1, Ob);
  let f = qpInstance.color;
  let g = qpInstance.strength;
  qpInstance =
[2024-09-26 03:46:51]  Renamed to createIbInstance
[2024-09-26 03:46:51]  Processing: 5%
[2024-09-26 03:46:51]  Renaming d
[2024-09-26 03:46:51]  Context:  static Qp(qpInstance, strengthValue) {
  let createIbInstance = new ib();
  var d = w.J(qpInstance.d0, Ob);
  var e = w.J(qpInstance.d1, Ob);
  let f = qpInstance.color;
  let g = qpInstance.strength;
[2024-09-26 03:46:52]  Renamed to distanceCalculation
[2024-09-26 03:46:52]  Processing: 5%
[2024-09-26 03:46:52]  Renaming e
[2024-09-26 03:46:52]  Context:  static Qp(qpInstance, strengthValue) {
  let createIbInstance = new ib();
  var distanceCalculation = w.J(qpInstance.d0, Ob);
  var e = w.J(qpInstance.d1, Ob);
  let f = qpInstance.color;
  let g = qp
[2024-09-26 03:46:53]  Renamed to distanceCalculationD1
[2024-09-26 03:46:53]  Processing: 5%
[2024-09-26 03:46:53]  Renaming f
[2024-09-26 03:46:53]  Context:  static Qp(qpInstance, strengthValue) {
  let createIbInstance = new ib();
  var distanceCalculation = w.J(qpInstance.d0, Ob);
  var distanceCalculationD1 = w.J(qpInstance.d1, Ob);
  let f = qpInstance
[2024-09-26 03:46:53]  Renamed to currentQpInstance
[2024-09-26 03:46:53]  Processing: 5%
[2024-09-26 03:46:53]  Renaming g
[2024-09-26 03:46:53]  Context:  static Qp(qpInstance, strengthValue) {
  let createIbInstance = new ib();
  var distanceCalculation = w.J(qpInstance.d0, Ob);
  var distanceCalculationD1 = w.J(qpInstance.d1, Ob);
  let currentQpInsta
[2024-09-26 03:46:54]  Renamed to calculateDistance

..snip..

@Anooxy17 Are you able to run this again with --verbose and see if you get the error again? And if so, can you paste the relevant logs (or maybe the full logs as an attachment)? That may help narrow down where the issue might be coming from.


It looks like the problem is less that there should be a ,, and more that that something is adding the _static prefix to the variable where it presumably shouldn't be.

I can see that a lot of the function names have a static prefix; not sure if that ended up confusing the LLM when it was trying to come up with useful param renames or similar; but that is where I would start looking.

This is still my main theory though, particularly given the same _static calculateQualityParameter 'variable name' can be seen on lines 1327, 1329, 1330:

SyntaxError: Unexpected token, expected "," (1327:23)
  1325 |       return dataPointDetails;
  1326 |     }
> 1327 |     static Qp(_static calculateQualityParameter, qualityParameter) {
       |                       ^
  1328 |       let qualityCalculator = new InvestmentBalance();
  1329 |       var qualityParameterValue = _UtilityClass.J(_static calculateQualityParameter.d0, getPeWithEmptyStringUtil);
  1330 |       var qualityData = _UtilityClass.J(_static calculateQualityParameter.d1, getPeWithEmptyStringUtil);
    at vr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15472)
    at Lr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15798)

I haven't looked deeply at the code that handles variable names returned from openai, but I am assuming OpenAI said to use static calculateQualityParameter as a variable name, and then humanify prefixed it with _; or similar based on something like this:

@Anooxy17
Copy link
Author

So should I open it on openai again or try it locally? With which model?

@Anooxy17
Copy link
Author

@0xdevalias
errors.txt
It was made in OpenAI, not even went into over 70% now

@0xdevalias
Copy link

0xdevalias commented Sep 26, 2024

errors.txt
It was made in OpenAI, not even went into over 70% now

This error seems to be related to the attempt to assign a value to an object within a for loop, which isn't allowed:

SyntaxError: Unexpected token (3562:43)
  3560 |       if (this.M == null) {
  3561 |         this.M = new CustomAnimationHandler();
> 3562 |         for (var _________index = 0, _this.kLength = this.K; _________index < _this.kLength.length;) {
       |                                           ^
  3563 |           let kLengthValue = _this.kLength[_________index];
  3564 |           ++_________index;
  3565 |           kLengthValue.I = null;
    at vr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15472)
    at Lr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15798)
    at Object.parse (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:15:2885)
    at parse4 (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:21902:24)
    at async coreFormat (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:22355:7)
    at async formatWithCursor (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:22557:14)
    at async Object.format2 (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:23932:25)
    at async unminify (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:214:27)
    at async Command.<anonymous> (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/index.mjs:56814:3) {
  loc: { start: { line: 3562, column: 43 } },

While I haven't looked deeply into it, this part makes me wonder if it's an issue with webcrack and how it's choosing to inline certain variables/etc within for loops.

It seems humanify is currently using webcrack 2.13.0:

"webcrack": "^2.13.0"

Looking at the releases we can see that the latest version is 2.14.1:

Looking at the release notes for 2.14.0, there is a line that talks about extracting sequences from for loops; I wonder if that would also fix this issue:

It also seems to change how variables/parameters are named by default, which might give better starting names to pass to the LLM:

  • Mangle: names are inferred based on type (variable, function, parameter, class) and some expressions


@Anooxy17 You could potentially try cloning the humanify repo, bumping webcrack to the latest version in package.json, and then seeing if that resolves this issue.

I'll also note that this seems like it might actually be a different issue to what was reported initially, so even if bumping webcrack to the latest version helps solve it, it may still be worth looking deeper into the cause of the original issue.

@Anooxy17
Copy link
Author

@0xdevalias
Yeees, it exactly looks like different error now, im crazy right now, doesnt matter how much I try, I cant really deobfuscate this file 😆
I will try when I came back to home and let u know then, ty

@0xdevalias
Copy link

0xdevalias commented Sep 27, 2024

Looks like @Yusufkulcu is hitting a similar sort of error now, so perhaps they can try the workaround steps above and see if that helps in their case too:

SyntaxError: Unexpected token, expected "," (74:70)
72 |      });
73 |    };
74 |    subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
   |                                                                       ^
75 |      var sourceObject = this.source;
76 |      return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
77 |    };

Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures.

6blF.txt

main.txt

image

..snip..

image

..snip..

@Yusufkulcu I'm glad that workaround helped get around the first issue :)

That new error you're running into seems to now be the same/similar to the errors being discussed in this issue:

You might like to try the potential solution I described in this comment, RE: cloning the humanify repo and bumping the webcrack version in package.json to the latest version (2.14.1):

Originally posted by @0xdevalias in #111 (comment)

@0xdevalias
Copy link

0xdevalias commented Sep 27, 2024

Looks like @Yusufkulcu is hitting a similar sort of error now

SyntaxError: Unexpected token, expected "," (74:70)
72 |      });
73 |    };
74 |    subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
   |                                                                       ^
75 |      var sourceObject = this.source;
76 |      return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
77 |    };

6blF.txt

main.txt

I made a few patches to my locally checked out version of humanify to help provide better output info + skip through to the relevant files that seem to be causing errors:

src/unminify.ts:

diff --git a/src/unminify.ts b/src/unminify.ts
index 948b4df..ff95ae0 100644
--- a/src/unminify.ts
+++ b/src/unminify.ts
@@ -9,22 +9,42 @@ export async function unminify(
   plugins: ((code: string) => Promise<string>)[] = []
 ) {
   ensureFileExists(filename);
+
+  console.log(`Reading input file: ${filename}`);
   const bundledCode = await fs.readFile(filename, "utf-8");
+
+  console.log('Running webcrack to extract/decrypt bundled code...');
   const extractedFiles = await webcrack(bundledCode, outputDir);
 
+  console.log(`Unbundled ${extractedFiles.length} files from ${filename} into ${outputDir}`);
+
   for (let i = 0; i < extractedFiles.length; i++) {
-    console.log(`Processing file ${i + 1}/${extractedFiles.length}`);
-
     const file = extractedFiles[i];
+
+    console.log(`Processing file ${i + 1}/${extractedFiles.length} (${file.path})`);
+
+    // Skip extracted files till we find the one we actually want to try and process
+    if (file.path !== `${outputDir}/6blF.js`) {
+      console.log('  [hack] Skipping files that are not the one we want to process');
+      continue;
+    }
+
     const code = await fs.readFile(file.path, "utf-8");
-    const formattedCode = await plugins.reduce(
-      (p, next) => p.then(next),
-      Promise.resolve(code)
-    );
+    if (code) {
+      const formattedCode = await plugins.reduce(
+        (p, next) => p.then(next),
+        Promise.resolve(code)
+      );
 
-    verbose.log("Input: ", code);
-    verbose.log("Output: ", formattedCode);
+      verbose.log("  Input: ", code);
+      verbose.log("  Output: ", formattedCode);
 
-    await fs.writeFile(file.path, formattedCode);
+      await fs.writeFile(file.path, formattedCode);
+    }
+    else {
+      verbose.log(`  Skipping empty file ${i + 1} (${file.path})`);
+    }
   }
+
+  console.log(`Unminified (or skipped) ${extractedFiles.length} files from ${filename} into ${outputDir}`);
 }

Then tried running it against main.txt, configured to skip all of the extracted files except for output/6blF.js; but I didn't seem to run into an error when I ran it (for reference, I hadn't bumped my version of webcrack to the latest before running this):

This is how the lines that originally caused the error seemed to look like after being extracted with webcrack:

  // ..snip..
  _0x223285.prototype._subscribe = function (_0x3becc8) {
    var _0x2e0ffb = this.source;
    return _0x2e0ffb && _0x2e0ffb.subscribe(_0x3becc8);
  };
  // ..snip..

And this is how the equivalent code looked after my run of humanify had finished with it:

  // ..snip..
  createSubscription.prototype._subscribe = function (___dataProcessor) {
    var sourceSubscription = this.source;
    return sourceSubscription && sourceSubscription.subscribe(___dataProcessor);
  };
  // ..snip..

Which we can contrast against the version that @Yusufkulcu got the error with, which seemed to end up as:

  // ..snip..
  subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
    var sourceObject = this.source;
    return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
  };
  // ..snip..

In the original code, the _0x3becc8 seems to only exist in that functions parameter + the usage of it within the function. That is the same for ___dataProcessor within my version. So my best guess is that with @Yusufkulcu's version, the LLM must have chosen the invalid variable name _subscribeHandler.syncErrorThrown as a replacement or similar, but I can't really validate that as the screenshots/output shown in this comment #111 (comment) seem to not mention what variable renames were being applied; which should have been shown in the output from openaiRename (Ref) (assuming they were running humanify openai, and not humanify local or similar?)


@jehna probably knows the answer to this better.. but from memory of skimming through the humanify code I don't think there is any context shared between the files being processed; so I wouldn't have expected the 'skip other files' hack I implemented above should have impacted the outcome.. so I'm even more confused as to why I can't reproduce the error that @Yusufkulcu was seeing.


Edit: One thing I noticed is that when @Yusufkulcu was unpacking it output/6blF.js was file 63, yet when I was running unpacking it was file 66, so it seems webcrack's file order may not be the same each time it's run (even though the filenames seem consistent, at least based on this one example)

@Yusufkulcu
Copy link

Looks like @Yusufkulcu is hitting a similar sort of error now, so perhaps they can try the workaround steps above and see if that helps in their case too:

SyntaxError: Unexpected token, expected "," (74:70)
72 |      });
73 |    };
74 |    subscribeHandler.prototype._subscribe = function (_subscribeHandler.syncErrorThrown) {
   |                                                                       ^
75 |      var sourceObject = this.source;
76 |      return sourceObject && sourceObject.subscribe(_subscribeHandler.syncErrorThrown);
77 |    };

Thanks for the suggestion, it doesn't give that error anymore, but now I'm getting another error. I get the following error in file 63. I've added the original file and the file where I got the error below. It's a pretty long mistake, so I added some more pictures.

6blF.txt
main.txt

image
..snip..
image
..snip..

@Yusufkulcu I'm glad that workaround helped get around the first issue :)
That new error you're running into seems to now be the same/similar to the errors being discussed in this issue:

You might like to try the potential solution I described in this comment, RE: cloning the humanify repo and bumping the webcrack version in package.json to the latest version (2.14.1):

Originally posted by @0xdevalias in #111 (comment)

Thank you very much for your reply. I updated the "webcrack" package, but the same problem persists. The problem is another file this time. Interestingly, I can't find the file with the error.

Screenshot_20240927_110444_Chrome
Screenshot_20240927_110512_Chrome
Screenshot_20240927_110742_Chrome

@Yusufkulcu
Copy link

@0xdevalias I am also grateful for your detailed Explanations

@Yusufkulcu
Copy link

Instead of writing it on my own record, I mixed it up and wrote it here. Sorry

@0xdevalias
Copy link

0xdevalias commented Sep 27, 2024

I updated the "webcrack" package, but the same problem persists. The problem is another file this time. Interestingly, I can't find the file with the error.

@Yusufkulcu Are you running humanify openai or one of the other commands?

Are you running with --verbose?

It looks like the screenshots of your latest output are still missing the critical detail I mentioned above; of what the before and after names are when the variables are renamed.


Instead of writing it on my own record, I mixed it up and wrote it here. Sorry

@Yusufkulcu Thats fine; now that you're getting the same types of errors; this is a good place to centralise the discussion of these types of error.

@Yusufkulcu
Copy link

I updated the "webcrack" package, but the same problem persists. The problem is another file this time. Interestingly, I can't find the file with the error.

@Yusufkulcu Are you running humanify openai or one of the other commands?

Are you running with --verbose?

It looks like the screenshots of your latest output are still missing the critical detail I mentioned above; of what the before and after names are when the variables are renamed.

Instead of writing it on my own record, I mixed it up and wrote it here. Sorry

@Yusufkulcu Thats fine; now that you're getting the same types of errors; this is a good place to centralise the discussion of these types of error.

I'm using OpenAI. Right now - I ran it with -verbose . How can I post the Verbose log here

@0xdevalias
Copy link

0xdevalias commented Sep 27, 2024

Right now - I ran it with -verbose . How can I post the Verbose log here

@Yusufkulcu Cool, does it have the log lines that talk about 'Renaming VAR' and 'Renamed to NEWVAR' or similar? Did it still get the error?

It should look something like this:

..snip..

Processing file 66/559 (output/6blF.js)

[2024-09-27 05:35:05]  Renaming _0x29881a
[2024-09-27 05:35:05]  Context:  var _0x29881a = require("./FFOo.js");
var _0x21aff1 = require("./L/V9.js");
var _0x332379 = require("./6ahw.js");
var _0x51037e = require("./xTla.js");
var _0x456d11 = require("./y3By.js");
var _0x2ad
[2024-09-27 05:35:06]  Renamed to FFOoModule

[2024-09-27 05:35:06]  Processing: 2%
[2024-09-27 05:35:06]  Renaming _0x21aff1
[2024-09-27 05:35:06]  Context:  var FFOoModule = require("./FFOo.js");
var _0x21aff1 = require("./L/V9.js");
var _0x332379 = require("./6ahw.js");
var _0x51037e = require("./xTla.js");
var _0x456d11 = require("./y3By.js");
var _0x2a
[2024-09-27 05:35:06]  Renamed to versionChecker

..snip..

I usually copy/paste all of the text output from my terminal into a .txt file (eg. With notepad if you're on windows); then you should be able to attach that to a comment here.

@Yusufkulcu
Copy link

Right now - I ran it with -verbose . How can I post the Verbose log here

@Yusufkulcu Cool, does it have the log lines that talk about 'Renaming VAR' and 'Renamed to NEWVAR' or similar? Did it still get the error?

It should look something like this:

..snip..

Processing file 66/559 (output/6blF.js)

[2024-09-27 05:35:05]  Renaming _0x29881a
[2024-09-27 05:35:05]  Context:  var _0x29881a = require("./FFOo.js");
var _0x21aff1 = require("./L/V9.js");
var _0x332379 = require("./6ahw.js");
var _0x51037e = require("./xTla.js");
var _0x456d11 = require("./y3By.js");
var _0x2ad
[2024-09-27 05:35:06]  Renamed to FFOoModule

[2024-09-27 05:35:06]  Processing: 2%
[2024-09-27 05:35:06]  Renaming _0x21aff1
[2024-09-27 05:35:06]  Context:  var FFOoModule = require("./FFOo.js");
var _0x21aff1 = require("./L/V9.js");
var _0x332379 = require("./6ahw.js");
var _0x51037e = require("./xTla.js");
var _0x456d11 = require("./y3By.js");
var _0x2a
[2024-09-27 05:35:06]  Renamed to versionChecker

..snip..

I usually copy/paste all of the text output from my terminal into a .txt file (eg. With notepad if you're on windows); then you should be able to attach that to a comment here.

Screenshot_20240927_132354_Chrome
Screenshot_20240927_132521_Chrome

@Yusufkulcu
Copy link

@0xdevalias

I noticed that the syntax error appears in a different file every time. This is something I don't understand.

@Yusufkulcu
Copy link

It's really strange, the error occurs in a different file each time. I am adding the error logs below. "main.txt" is the original file, "+Branch.txt" is the file from which the error was received.

I use the "humanify openi" command

image

image

image

+Dal.txt

main.txt

verbose-log.txt

@Yusufkulcu
Copy link

@0xdevalias @jehna I wonder if you have any ideas or suggestions.

@j4k0xb
Copy link
Contributor

j4k0xb commented Sep 28, 2024

I think I found the root issue:

The LLM generates this.kLength as a name -> detected as invalid and changed to _this.kLength:

let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;
while (renames.has(safeRenamed)) {
safeRenamed = `_${safeRenamed}`;
}
renames.add(safeRenamed);
smallestScope.scope.rename(smallestScopeNode.name, safeRenamed);

The proper fix would be to use toIdentifier from @babel/types

I noticed that the syntax error appears in a different file every time. This is something I don't understand.

LLM use a random sampling technique

Looking at the release notes for 2.14.0, there is a line that talks about extracting sequences from for loops; I wonder if that would also fix this issue:

That's a different type of for-loop. But I'd recommend updating either way because of other bugs 😅
edit: #38 it's already the newest, just not in package.json for some reason

@Yusufkulcu
Copy link

toIdentifier

Where should the "toIdentifier" function be used? I don't fully understand the solution to the problem

@j4k0xb
Copy link
Contributor

j4k0xb commented Sep 28, 2024

Gonna make a PR in a few minutes

@Yusufkulcu
Copy link

Gonna make a PR in a few minutes

I am waiting

@Yusufkulcu
Copy link

@j4k0xb

This fix seems to have worked, the files that previously gave errors are now progressing smoothly. I will inform you when the process is completed.

@0xdevalias
Copy link

0xdevalias commented Sep 29, 2024

verbose-log.txt

@Yusufkulcu Thanks for that verbose log, it seems to confirm that the bug is what I thought it might have been, with the LLM choosing an invalid variable name:

It looks like the problem is less that there should be a ,, and more that that something is adding the _static prefix to the variable where it presumably shouldn't be.

I can see that a lot of the function names have a static prefix; not sure if that ended up confusing the LLM when it was trying to come up with useful param renames or similar; but that is where I would start looking.

This is still my main theory though, particularly given the same _static calculateQualityParameter 'variable name' can be seen on lines 1327, 1329, 1330:

SyntaxError: Unexpected token, expected "," (1327:23)
  1325 |       return dataPointDetails;
  1326 |     }
> 1327 |     static Qp(_static calculateQualityParameter, qualityParameter) {
       |                       ^
  1328 |       let qualityCalculator = new InvestmentBalance();
  1329 |       var qualityParameterValue = _UtilityClass.J(_static calculateQualityParameter.d0, getPeWithEmptyStringUtil);
  1330 |       var qualityData = _UtilityClass.J(_static calculateQualityParameter.d1, getPeWithEmptyStringUtil);
    at vr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15472)
    at Lr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15798)

I haven't looked deeply at the code that handles variable names returned from openai, but I am assuming OpenAI said to use static calculateQualityParameter as a variable name, and then humanify prefixed it with _; or similar based on something like this:

Originally posted by @0xdevalias in #117 (comment)

In the original code, the _0x3becc8 seems to only exist in that functions parameter + the usage of it within the function. That is the same for ___dataProcessor within my version. So my best guess is that with @Yusufkulcu's version, the LLM must have chosen the invalid variable name _subscribeHandler.syncErrorThrown as a replacement or similar, but I can't really validate that as the screenshots/output shown in this comment #111 (comment) seem to not mention what variable renames were being applied; which should have been shown in the output from openaiRename (Ref) (assuming they were running humanify openai, and not humanify local or similar?)

Originally posted by @0xdevalias in #117 (comment)

While the context it's showing doesn't make a lot of sense to me as to where _0x53274b fits into it, we can see that the variable name chosen by the LLM was setChangeDetection.prototype.updateValue, which obviously isn't valid for a single variable name:

[2024-09-27 18:56:10]  Renaming _0x53274b
[2024-09-27 18:56:10]  Context:  setChangeDetection.prototype.writeValue = function (initModules) {
    if (initModules % 1 !== initModules) {
      this.value = Math.round(initModules);
      this.preValue = initModules;
      this.changeDet
[2024-09-27 18:56:11]  Renamed to setChangeDetection.prototype.updateValue

I noticed that the syntax error appears in a different file every time. This is something I don't understand.

@Yusufkulcu This is happening because the bug is related to the LLM suggesting an invalid variable name. Because the LLM can come up with different answers every time it's run (related: #97), this is why the error ends up being in a different file each time.


I think I found the root issue:

The LLM generates this.kLength as a name -> detected as invalid and changed to _this.kLength:

@j4k0xb Agreed, that's the bug as I see it too. Thanks for pointing out the safeRenamed / isValidIdentifier part. I knew I read something about prefixing variables somewhere (eg. #8, #20), but hadn't looked deeply into the code to figure out where that was happening.


The proper fix would be to use toIdentifier from @babel/types

@j4k0xb @jehna From a 2sec search I couldn't find rendered docs, but here's the relevant source for each:

toIdentifier definitely seems like a more robust approach than the current 'prefix with _' approach for sure.

Though I wonder if a 'proper fix' should also involve tweaking how we prompt for/filter the suggestions coming back from the LLM itself as well. Like instead of just forcing an invalid suggestion to be valid (with toIdentifier), we could detect that it's invalid (with isValidIdentifier) and then provide that feedback to the LLM, asking it to give a new suggestion; probably with some max retry limit; after which we could fall back to using the invalid suggestion run through toIdentifier, or log a warning and leave it un-renamed or similar.


Looking at the release notes for 2.14.0, there is a line that talks about extracting sequences from for loops; I wonder if that would also fix this issue:

That's a different type of for-loop. But I'd recommend updating either way because of other bugs 😅

@j4k0xb Haha, yeah, that's fair enough. I didn't look too deeply + we didn't have a lot more information at the time so was just throwing out ideas/potentials 😅


Where should the "toIdentifier" function be used? I don't fully understand the solution to the problem

@Yusufkulcu Basically on this line:

let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;

Since toIdentifier calls isValidIdentifier within itself, the basic workaround change could be as simple as:

- let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;
+ let safeRenamed = toIdentifier(renamed);

Gonna make a PR in a few minutes

@j4k0xb Thanks for making a PR with the workaround fix!

Will add some thoughts to it (though realistically they can probably be handled as a separate PR)

@j4k0xb
Copy link
Contributor

j4k0xb commented Sep 29, 2024

Though I wonder if a 'proper fix' should also involve tweaking how we prompt for/filter the suggestions coming back from the LLM itself as well.

Yeah there's for sure a way to improve (also mentioned in other issues afaik) if you're willing to do the work.
That PR is just a quick fix to prevent crashing.

@0xdevalias
Copy link

0xdevalias commented Sep 29, 2024

also mentioned in other issues afaik

@j4k0xb Yup, seems I mentioned a similar pattern in this comment:

Made a reference back to the suggestion here in this followup comment for continuity:

@Yusufkulcu
Copy link

I had a question. The corresponding file size in the image is too large (134881 lines). And the processing of the file seems to take a very long time. Is there a faster way to do this? If the terminal screen closes the process will reset and that would be very sad

image

@Yusufkulcu
Copy link

verbose-log.txt

@Yusufkulcu Thanks for that verbose log, it seems to confirm that the bug is what I thought it might have been, with the LLM choosing an invalid variable name:

It looks like the problem is less that there should be a ,, and more that that something is adding the _static prefix to the variable where it presumably shouldn't be.
I can see that a lot of the function names have a static prefix; not sure if that ended up confusing the LLM when it was trying to come up with useful param renames or similar; but that is where I would start looking.

This is still my main theory though, particularly given the same _static calculateQualityParameter 'variable name' can be seen on lines 1327, 1329, 1330:

SyntaxError: Unexpected token, expected "," (1327:23)
  1325 |       return dataPointDetails;
  1326 |     }
> 1327 |     static Qp(_static calculateQualityParameter, qualityParameter) {
       |                       ^
  1328 |       let qualityCalculator = new InvestmentBalance();
  1329 |       var qualityParameterValue = _UtilityClass.J(_static calculateQualityParameter.d0, getPeWithEmptyStringUtil);
  1330 |       var qualityData = _UtilityClass.J(_static calculateQualityParameter.d1, getPeWithEmptyStringUtil);
    at vr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15472)
    at Lr (file:///C:/Users/ktepe/AppData/Roaming/npm/node_modules/humanifyjs/dist/babel-C_YYVHCf.mjs:14:15798)

I haven't looked deeply at the code that handles variable names returned from openai, but I am assuming OpenAI said to use static calculateQualityParameter as a variable name, and then humanify prefixed it with _; or similar based on something like this:

Originally posted by @0xdevalias in #117 (comment)

In the original code, the _0x3becc8 seems to only exist in that functions parameter + the usage of it within the function. That is the same for ___dataProcessor within my version. So my best guess is that with @Yusufkulcu's version, the LLM must have chosen the invalid variable name _subscribeHandler.syncErrorThrown as a replacement or similar, but I can't really validate that as the screenshots/output shown in this comment #111 (comment) seem to not mention what variable renames were being applied; which should have been shown in the output from openaiRename (Ref) (assuming they were running humanify openai, and not humanify local or similar?)
Originally posted by @0xdevalias in #117 (comment)

While the context it's showing doesn't make a lot of sense to me as to where _0x53274b fits into it, we can see that the variable name chosen by the LLM was setChangeDetection.prototype.updateValue, which obviously isn't valid for a single variable name:

[2024-09-27 18:56:10]  Renaming _0x53274b
[2024-09-27 18:56:10]  Context:  setChangeDetection.prototype.writeValue = function (initModules) {
    if (initModules % 1 !== initModules) {
      this.value = Math.round(initModules);
      this.preValue = initModules;
      this.changeDet
[2024-09-27 18:56:11]  Renamed to setChangeDetection.prototype.updateValue

I noticed that the syntax error appears in a different file every time. This is something I don't understand.

@Yusufkulcu This is happening because the bug is related to the LLM suggesting an invalid variable name. Because the LLM can come up with different answers every time it's run (related: #97), this is why the error ends up being in a different file each time.

I think I found the root issue:
The LLM generates this.kLength as a name -> detected as invalid and changed to _this.kLength:

@j4k0xb Agreed, that's the bug as I see it too. Thanks for pointing out the safeRenamed / isValidIdentifier part. I knew I read something about prefixing variables somewhere (eg. #8, #20), but hadn't looked deeply into the code to figure out where that was happening.

The proper fix would be to use toIdentifier from @babel/types

@j4k0xb @jehna From a 2sec search I couldn't find rendered docs, but here's the relevant source for each:

toIdentifier definitely seems like a more robust approach than the current 'prefix with _' approach for sure.

Though I wonder if a 'proper fix' should also involve tweaking how we prompt for/filter the suggestions coming back from the LLM itself as well. Like instead of just forcing an invalid suggestion to be valid (with toIdentifier), we could detect that it's invalid (with isValidIdentifier) and then provide that feedback to the LLM, asking it to give a new suggestion; probably with some max retry limit; after which we could fall back to using the invalid suggestion run through toIdentifier, or log a warning and leave it un-renamed or similar.

Looking at the release notes for 2.14.0, there is a line that talks about extracting sequences from for loops; I wonder if that would also fix this issue:

That's a different type of for-loop. But I'd recommend updating either way because of other bugs 😅

@j4k0xb Haha, yeah, that's fair enough. I didn't look too deeply + we didn't have a lot more information at the time so was just throwing out ideas/potentials 😅

Where should the "toIdentifier" function be used? I don't fully understand the solution to the problem

@Yusufkulcu Basically on this line:

let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;

Since toIdentifier calls isValidIdentifier within itself, the basic workaround change could be as simple as:

- let safeRenamed = isValidIdentifier(renamed) ? renamed : `_${renamed}`;
+ let safeRenamed = toIdentifier(renamed);

Gonna make a PR in a few minutes

@j4k0xb Thanks for making a PR with the workaround fix!

Will add some thoughts to it (though realistically they can probably be handled as a separate PR)

Thank you for your help, my problem has been solved

@Yusufkulcu
Copy link

I had a question. The corresponding file size in the image is too large (134881 lines). And the processing of the file seems to take a very long time. Is there a faster way to do this? If the terminal screen closes the process will reset and that would be very sad

image

@0xdevalias Do you have any ideas on this?

@0xdevalias
Copy link

The corresponding file size in the image is too large (134881 lines). And the processing of the file seems to take a very long time. Is there a faster way to do this? If the terminal screen closes the process will reset and that would be very sad

@0xdevalias Do you have any ideas on this?

@Yusufkulcu I don't particularly have any ideas on it except for making sure the terminal screen doesn't close, or using something like screen or tmux or similar to run it in a background sort of shell.

I assume the running slow is related to overall filesize and the calls to the LLM, not just inefficiency in the code, but this recent PR may slightly speed things up in the AST parsing/renaming aspect:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants