hud-sdk 1.4.3 → 1.4.4

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.
@@ -1,2 +1,2 @@
1
- !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(global,(()=>(()=>{"use strict";var e={2602:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.hudConfig=r.HudDynamicConfigSchema=void 0;const n=t(1569),o=t(7182);r.HudDynamicConfigSchema=n.z.object({aggregationInterval:n.z.number(),flowMetricInterval:n.z.number(),graphqlInterval:n.z.number()});const s=process.env.HUD_HOST||"https://api-prod.hud.io",i=process.env.HUD_MONITOR_MODULES,a=i?i.split(","):[],c={sink:{url:s,timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get"},logger:{default:{levels:{app:"warn",worker:"warn",instrument:"warn"},console:!1},verbose:{levels:{app:"info",worker:"info",instrument:"info"},console:!0},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"},console:!0}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,hudModuleName:o.SDK_MODULE_NAME,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,logPerfInterval:3e5,endpointsInterval:18e5,endpointsFirstSendWaitTime:12e4,huddBinWidth:1.2,workerGrace:6e4,workerTimeout:2e4,timeoutOnInit:3e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:{enable:!0,skipOnNodeFlag:!0},editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:"94a210f3-861c-4e18-ab27-6b6c19437c9d",wrapVarPrefix:"_HUD",monitorNodeModules:a,frameworksToPatch:new Map([["express",{version:"<=4",patcher:"express"}],["koa",{version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{version:"14 - 16",patcher:"graphql"}],["http",{version:"*",patcher:"http"}],["https",{version:"*",patcher:"http"}],["@nestjs/core/interceptors/interceptors-consumer",{version:"*",patcher:"nestjsInterceptor"}],["@nestjs/core/router/router-execution-context",{version:"*",patcher:"nestjsRouterExecutionContext"}],["@nestjs/microservices/context/rpc-context-creator",{version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],["kafkajs",{version:">=1.4.0",patcher:"kafkajs"}],["@codegenie/serverless-express/src/frameworks/express.js",{version:"^4.1.0",patcher:"serverlessExpressFrameworkExpress"}],["@codegenie/serverless-express",void 0]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,maxWrappedFileSize:2831155,express:{routeNamesVarName:"hudRoutes",layerStateVarName:"hudState",markedVarName:"hudMarked",wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22"],codegenMode:process.env.HUD_CODEGEN_MODE??"swc",hudPatchedName:"hudPatched",hudMetricName:"hudMetric",dynamicConfig:{aggregationInterval:3e4,flowMetricInterval:3e4,graphqlInterval:3e4},suppressTraces:!0,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202};r.hudConfig=function(e={}){return{...c,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"},console:!1},verbose:{levels:{app:"info",worker:"info",instrument:"info"},console:!0},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"},console:!0}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),r.default=r.hudConfig},7182:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.SDK_MODULE_NAME=void 0,r.SDK_MODULE_NAME="hud-sdk"},1569:e=>{e.exports=require("zod")}},r={};return function t(n){var o=r[n];if(void 0!==o)return o.exports;var s=r[n]={exports:{}};return e[n](s,s.exports,t),s.exports}(2602)})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(()=>(()=>{"use strict";var e={2602:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.hudConfig=t.isValidUserInput=t.updateUserConfigFromInit=t.updateUserConfigFromFile=t.updateUserConfigFromEnv=t.RawUserConfigSchema=t.HudDynamicConfigSchema=void 0;const s=i(r(9896)),a=r(1569),c=r(7182),u=r(2826);function l(e){return null!=e&&""!==e&&"string"==typeof e}t.HudDynamicConfigSchema=a.z.object({aggregationInterval:a.z.number(),flowMetricInterval:a.z.number(),graphqlInterval:a.z.number()}),t.RawUserConfigSchema=a.z.object({key:a.z.string().optional(),service:a.z.string().optional(),includeModules:a.z.array(a.z.string()),enable:a.z.boolean().optional()}),t.updateUserConfigFromEnv=function(){const e=process.env.HUD_KEY,r=process.env.HUD_SERVICE,n=process.env.HUD_MONITOR_MODULES||process.env.HUD_INCLUDE_MODULES;e&&(t.hudConfig.userConfig.key={value:e,source:"ENV"}),r&&(t.hudConfig.userConfig.service={value:r,source:"ENV"}),n&&(t.hudConfig.userConfig.includeModules={value:n.split(","),source:"ENV"})},t.updateUserConfigFromFile=function(e,r,n){const o=(0,u.getConfigPath)();if(o)try{const e=s.readFileSync(o,"utf8"),r=t.RawUserConfigSchema.partial().parse(JSON.parse(e));Object.entries(r).forEach((([e,r])=>{!function(e,t,r){e[t]=r}(t.hudConfig.userConfig,e,{value:r,source:"FILE"})}))}catch(t){throw t instanceof a.ZodError?t.errors.forEach((t=>{const r=t.path.join(".");e(o,r)})):"EACCES"===t.code?n(o):t.message?.includes("Unexpected")&&t.message?.includes("JSON")&&r(o,t.message),t}},t.updateUserConfigFromInit=function(e,r){void 0!==e&&(t.hudConfig.userConfig.key={value:e,source:"INIT"}),void 0!==r&&(t.hudConfig.userConfig.service={value:r,source:"INIT"})},t.isValidUserInput=function(){const{key:e,service:r}=t.hudConfig.userConfig;return void 0!==e&&void 0!==r&&l(e.value)&&l(r.value)};const d=process.env.HUD_HOST||"https://api-prod.hud.io",p=process.env.HUD_MONITOR_MODULES,f=p?p.split(","):[],g={sink:{url:d,timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get"},logger:{default:{levels:{app:"warn",worker:"warn",instrument:"warn"},console:!1},verbose:{levels:{app:"info",worker:"info",instrument:"info"},console:!0},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"},console:!0}},userConfig:{includeModules:{value:[],source:"DEFAULT"}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,hudModuleName:c.SDK_MODULE_NAME,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,logPerfInterval:3e5,endpointsInterval:18e5,endpointsFirstSendWaitTime:12e4,huddBinWidth:1.2,workerGrace:6e4,workerTimeout:2e4,timeoutOnInit:3e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:{enable:!0,skipOnNodeFlag:!0},editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:"94a210f3-861c-4e18-ab27-6b6c19437c9d",wrapVarPrefix:"_HUD",monitorNodeModules:f,frameworksToPatch:new Map([["express",{version:"<=4",patcher:"express"}],["koa",{version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{version:"14 - 16",patcher:"graphql"}],["http",{version:"*",patcher:"http"}],["https",{version:"*",patcher:"http"}],["@nestjs/core/interceptors/interceptors-consumer",{version:"*",patcher:"nestjsInterceptor"}],["@nestjs/core/router/router-execution-context",{version:"*",patcher:"nestjsRouterExecutionContext"}],["@nestjs/microservices/context/rpc-context-creator",{version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],["kafkajs",{version:">=1.4.0",patcher:"kafkajs"}],["@codegenie/serverless-express/src/frameworks/express.js",{version:"^4.1.0",patcher:"serverlessExpressFrameworkExpress"}],["@codegenie/serverless-express",void 0]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,maxWrappedFileSize:2831155,express:{routeNamesVarName:"hudRoutes",layerStateVarName:"hudState",markedVarName:"hudMarked",wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22"],codegenMode:process.env.HUD_CODEGEN_MODE??"swc",hudPatchedName:"hudPatched",hudMetricName:"hudMetric",dynamicConfig:{aggregationInterval:3e4,flowMetricInterval:3e4,graphqlInterval:3e4},suppressTraces:!0,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202};t.hudConfig=function(e={}){return{...g,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"},console:!1},verbose:{levels:{app:"info",worker:"info",instrument:"info"},console:!0},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"},console:!0}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),t.default=t.hudConfig},8841:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.noopInit=t.noop=t.getConfigPath=t.isHudEnabled=void 0;const s=i(r(9896)),a=i(r(6928));function c(){try{const e=process.env.HUD_CONFIG_PATH;if(e)return s.existsSync(e)?e:void 0;let t=__dirname;for(;"/"!==t;){const e=`${t}/hud.config`;if(s.existsSync(e))return e;t=a.dirname(t)}}catch(e){return}}t.isHudEnabled=function(e,t){if("false"===process.env.HUD_ENABLE)return!1;const r=c();let n;if(r)try{if(n=JSON.parse(s.readFileSync(r,"utf8")),!1===n.enable)return!1}catch(n){throw"EACCES"===n.code?t(r):e(r,n instanceof Error?n.message:void 0),n}return"true"===process.env.HUD_ENABLE||!0===n?.enable},t.getConfigPath=c,t.noop=function(...e){},t.noopInit=async function(e,t){}},2826:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(8841),t)},7182:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SDK_MODULE_NAME=void 0,t.SDK_MODULE_NAME="hud-sdk"},1569:e=>{e.exports=require("zod")},9896:e=>{e.exports=require("fs")},6928:e=>{e.exports=require("path")}},t={};return function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(2602)})()));
2
2
  //# sourceMappingURL=config.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(global,(()=>(()=>{"use strict";var e={1019:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(n(5809));o(n(5809),t),t.default=i.default},3830:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getHudAwaitSequenceElement=t.isHudAwaitSequence=void 0;const o=n(6346),s=n(9514),i=r(n(1019));t.isHudAwaitSequence=function(e){if(e.expressions.length<2)return!1;const t=e.expressions[e.expressions.length-1];return!!o.types.isIdentifier(t)&&!!t.name.startsWith(i.default.wrapVarPrefix)},t.getHudAwaitSequenceElement=function(e){const t=e.expressions[0];if(!o.types.isAssignmentExpression(t))throw new s.HudUnsupportedError("Expected assignment expression");const{left:n,right:r}=t;if(!o.types.isIdentifier(n)||!n.name.startsWith(i.default.wrapVarPrefix))throw new s.HudUnsupportedError("Expected identifier starting with "+i.default.wrapVarPrefix);return r}},5600:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseDeclarations=t.fixSourceMap=void 0;const a=n(4634),l=n(692),c=s(n(6346)),u=s(n(6982)),d=n(5913),p=i(n(6760)),f=i(n(1019)),y=n(9514),m=n(3645),g=n(7892),h=n(1513),v=n(3118),E=n(949),_=n(1377),b={babelrc:!1,configFile:!1};function S(e){let t;return t="string"==typeof e?JSON.parse(e):e,t.sources=t.sources.map((e=>e.replace(/^webpack:\/\/(?:@[^/]+?[/])?[^/]+\//,""))),t}t.fixSourceMap=S,t.parseDeclarations=async function(e,t=null){const{code:n,map:r,filename:o,hasInputMap:s,bundlerBuildId:i,bundlerBuildIdGenerated:w}=e,C=[],x=n.replace(/_functionId = "(\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b)"/g,(function(e,...t){if(t[0]){const n=e.indexOf(t[0]),r=n+t[0].length;return e.slice(0,n)+"00000000-0000-0000-0000-000000000000"+e.slice(r)}return e})),P=S(r);return await a.SourceMapConsumer.with(P,null,(async e=>{_.worker_logger.debug("Parsing code",{filename:o});const r=await c.parseAsync(n,b);if(_.worker_logger.debug("Parsed code to tree",{filename:o}),null===r)return;const a=[{type:l.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0}],S=new Set;_.worker_logger.debug("Traversing declarations",{filename:o}),t?.postMessage("eventlooptime"),c.traverse(r,{VariableDeclarator:{exit(t){if(!c.types.isIdentifier(t.node.id)||t.node.id.name!==`${f.default.wrapVarPrefix}_functionId`)return;if(!c.types.isStringLiteral(t.node.init))throw new Error("Expected string literal");const n=t.node.init.value,r=t.findParent((e=>e.isFunction()));if(null===r)throw new Error("Function node not found");if(!r.isFunction())throw new Error("Expected function node");if(void 0===r.node.loc||null===r.node.loc||void 0===r.node.start||void 0===r.node.end||null===r.node.start||null===r.node.end)throw new Error("Function node has no location");const l=function(e){const t=u.createHash("sha256");return t.update(e),t.digest("hex")}(x.slice(r.node.start,r.node.end)),y=r.node.async||!1,m=(0,E.getNodeLocation)(r.node,e),g=m.start.source??o,_=(0,h.getEntityType)(r),b=(0,d.getMethodKind)(r.node),S=(0,d.getContextualData)(r);S.symbol&&(S.symbol=(0,E.resolveSymbol)(e,S.symbol)),S.callback?.callee.symbol&&(S.callback.callee.symbol=(0,E.resolveSymbol)(e,S.callback.callee.symbol));const P=(0,v.getParameterInfo)(r,e),{siblingIndex:T,childrenCount:H}=a[a.length-1],O=a.slice(0,-1),D=(0,E.resolveSymbol)(e,{name:(0,d.getFunctionName)(r),sourcemap_location_hints:(0,E.getLocationList)(r.node)}),I={module:p.default.parse(g).name,symbol:D,context:S,file:g,type:_,format:"commonjs",parameters:P,async:y,start_line:m.start.line,end_line:m.end.line,start_column:m.start.column,source_code_hash:l,runtime_function_id:n,bundler_build_id:i,was_bundler_build_id_generated:w,has_input_map:s,scope_chain:O,methodKind:b,siblingIndex:T,childrenCount:H};C.push(I)}},[m.NamespaceScopeAlias]:{enter(t){const{node:n}=t;if(!(0,m.isNamespaceScopeable)(n))return;const r=a[a.length-1];let o=(0,g.getScope)(t);if(!o)return;o=(0,E.resolveScopeSymbols)(e,o);const s=r.childrenCount[o.type]||0,i={...o,childrenCount:{},siblingIndex:s};r.childrenCount[o.type]=s+1,a.push(i),S.add(n)},exit(e){if(S.has(e.node)){const t=a.pop();if(!t||t?.symbol?.name!==(0,g.getScope)(e)?.symbol?.name)throw new y.HudAssert("Scope name is the same as the node name");S.delete(e.node)}}}}),_.worker_logger.debug("Traversed declarations",{filename:o})})),C}},1513:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getEntityName=t.getEntityType=void 0;const r=n(6346),o=n(692),s=n(1377);t.getEntityType=function(e){const{node:t}=e;return r.types.isFunctionDeclaration(t)?o.EntityType.FunctionDeclaration:r.types.isFunctionExpression(t)?o.EntityType.FunctionExpression:r.types.isArrowFunctionExpression(t)?o.EntityType.FunctionArrow:r.types.isObjectMethod(t)?o.EntityType.ObjectMethod:r.types.isStaticBlock(t)||r.types.isClassMethod(t)?o.EntityType.ClassMethod:r.types.isClassPrivateMethod(t)?o.EntityType.ClassPrivateMethod:r.types.isClassDeclaration(t)?o.EntityType.ClassDeclaration:r.types.isClassExpression(t)?o.EntityType.ClassExpression:r.types.isForInStatement(t)||r.types.isForOfStatement(t)||r.types.isForStatement(t)?o.EntityType.ForLoop:r.types.isBlockStatement(t)?function(e){const t=e.parentPath.node;if(!(r.types.isFunctionDeclaration(t)||r.types.isFunctionExpression(t)||r.types.isArrowFunctionExpression(t)||r.types.isClassMethod(t)||r.types.isObjectMethod(t)||r.types.isClassPrivateMethod(t)))if(r.types.isIfStatement(t)){if("consequent"===e.parentKey)return o.EntityType.IfConsequent;if("alternate"===e.parentKey)return o.EntityType.IfAlternate;if("test"===e.parentKey)return o.EntityType.IfTest}else{if(r.types.isBlockStatement(t)||r.types.isProgram(t))return o.EntityType.Block;if(r.types.isTryStatement(t)){if("block"===e.parentKey)return o.EntityType.Try;if("finalizer"===e.parentKey)return o.EntityType.Finally}else{if(r.types.isCatchClause(t))return;if(r.types.isWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(r.types.isDoWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(!(r.types.isForStatement(t)||r.types.isForInStatement(t)||r.types.isForOfStatement(t)))return;if("test"===e.parentKey)return o.EntityType.ForTest;if("body"===e.parentKey)return o.EntityType.ForBlock}}}(e):r.types.isProgram(t)?o.EntityType.Program:r.types.isDoWhileStatement(t)?o.EntityType.DoWhile:r.types.isWhileStatement(t)?o.EntityType.While:r.types.isCatchClause(t)?o.EntityType.Catch:r.types.isObjectExpression(t)?o.EntityType.ObjectExpression:r.types.isWithStatement(t)?o.EntityType.With:r.types.isSwitchStatement(t)?o.EntityType.Switch:r.types.isSwitchCase(t)?o.EntityType.SwitchCase:r.types.isTryStatement(t)?o.EntityType.TryCatch:r.types.isIfStatement(t)?o.EntityType.If:o.EntityType.Other},t.getEntityName=function(e){return r.types.isFunctionDeclaration(e)?r.types.isIdentifier(e.id)?e.id.name:void s.worker_logger.info("Function declaration without an identifier"):r.types.isClassDeclaration(e)?r.types.isIdentifier(e.id)?e.id.name:void s.worker_logger.info("Class declaration without an identifier"):r.types.isFunctionExpression(e)||r.types.isClassExpression(e)?r.types.isIdentifier(e.id)?e.id.name:void 0:r.types.isClassMethod(e)?r.types.isIdentifier(e.key)?e.key.name:void s.worker_logger.info("Class method without an identifier"):r.types.isObjectMethod(e)?r.types.isIdentifier(e.key)?e.key.name:void s.worker_logger.info("Object method without an identifier"):r.types.isClassPrivateMethod(e)?r.types.isIdentifier(e.key.id)?e.key.id.name:void s.worker_logger.info("Class private method without an identifier"):void e.type}},3118:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getParameterInfo=void 0;const i=s(n(6346)),a=n(1377),l=n(692);function c(e,t=0){if(void 0!==e.loc&&null!==e.loc)return{line:e.loc.start.line,column:e.loc.start.column+t}}function u(e){return i.types.isIdentifier(e.argument)?{name:e.argument.name,type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e,e.argument.name.length+3)}:(a.worker_logger.warn("Unsupported rest element",{type:e.argument.type}),{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e)})}function d(e){var t;if(e)switch(e?.type){case"Identifier":return{name:(t=e).name,type:l.ParameterTypes[t.type],sourcemap_location_hint:c(t,t.name.length)};case"AssignmentPattern":return function(e,t,n){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),left:t,right:n}}(e,d(e.left),function(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"BigIntLiteral":case"DecimalLiteral":return{type:e.type,value:e.value};case"RegExpLiteral":return{type:e.type,value:e.pattern}}return{type:e.type}}(e.right));case"ArrayPattern":return function(e,t){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),elements:t}}(e,e.elements.map((e=>d(e))).filter((e=>void 0!==e)));case"RestElement":return u(e);case"ObjectPattern":{const t=[];return e.properties.forEach((e=>{if(i.types.isObjectProperty(e)){const n=i.types.isIdentifier(e.key)&&i.types.isIdentifier(e.value)||i.types.isAssignmentPattern(e.value)?void 0:d(e.key);t.push(function(e,t,n){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),key:t,value:n}}(e,n,d(e.value)))}else i.types.isRestElement(e)&&t.push(u(e))})),function(e,t){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),properties:t}}(e,t)}default:a.worker_logger.warn("Unsupported parameter type",{type:e.type})}}t.getParameterInfo=function(e,t){return e.node.params.map((e=>{try{return d(e)}catch(e){return}})).filter((e=>void 0!==e)).map((e=>{let n;if(void 0!==e.sourcemap_location_hint){const{name:r,line:o,column:s}=t.originalPositionFor({line:e.sourcemap_location_hint.line,column:e.sourcemap_location_hint.column});null===o||null===s?(a.worker_logger.info("Could not find location for parameter",{type:e.type}),n={line:-1,column:-1}):n={name:r??void 0,line:o,column:s}}return{...e,name:n?.name??e.name,type:e.type,sourcemap_location_hint:n??e.sourcemap_location_hint}}))}},7892:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getScope=void 0;const r=n(1513),o=n(5913),s=n(949);t.getScope=function(e){const t=(0,r.getEntityType)(e);if(t){const n=(0,r.getEntityName)(e.node);return{type:t,context:(0,o.getContextualData)(e),symbol:{name:n,sourcemap_location_hints:(0,s.getLocationList)(e.node)},methodKind:(0,o.getMethodKind)(e.node)}}}},949:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getNodeLocation=t.resolveScopeSymbols=t.resolveSymbol=t.getLocationList=void 0;const r=n(1377);function o(e,t){return{name:t.name,sourcemap_location_hints:t.sourcemap_location_hints.map((t=>{const n=e.originalPositionFor({line:t.line,column:t.column});return null===n.line||null===n.column?{name:t.name,line:-1,column:-1}:{name:n.name??void 0,line:n.line,column:n.column,resolved:!0}}))}}t.getLocationList=function(e){return e.loc?[{line:e.loc.start.line,column:e.loc.start.column}]:[]},t.resolveSymbol=o,t.resolveScopeSymbols=function(e,t){const{context:n}=t,r=n.symbol?o(e,n.symbol):void 0,s=o(e,t.symbol);return{...t,context:{...n,symbol:r},symbol:s}},t.getNodeLocation=function(e,t,n=void 0){const o=e.loc?.start,s=e.loc?.end;if(!o||!s)return r.worker_logger.info("Node without location",{filename:n,type:e.type}),{start:{source:null,line:-1,column:-1},end:{source:null,line:-1,column:-1}};const i=t.originalPositionFor({line:o.line,column:o.column}),a=t.originalPositionFor({line:s.line,column:s.column});return null!==i.line&&null!==i.column&&null!==a.line&&null!==a.column||(r.worker_logger.debug("Could not find location for function",{filename:n,type:e.type,locStart:o,locEnd:s}),i.line=-1,i.column=-1,a.line=-1,a.column=-1),{start:{source:i.source,line:i.line,column:i.column},end:{source:a.source,line:a.line,column:a.column}}}},3645:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNamespaceScopeable=t.isHudScopeable=t.NamespaceScopeAlias=t.ScopableAlias=void 0;const r=n(6346);t.ScopableAlias="ArrowFunctionExpression|BlockStatement|CatchClause|ClassMethod|ClassPrivateMethod|DeclareModule|DoExpression|DoWhileStatement|ForInStatement|ForOfStatement|ForStatement|FunctionDeclaration|FunctionExpression|IfStatement|LabeledStatement|ObjectMethod|StaticBlock|SwitchCase|TSModuleBlock|TryStatement|WhileStatement|WithStatement|ClassDeclaration|ClassExpression|ObjectExpression|SwitchStatement",t.NamespaceScopeAlias="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod|ClassMethod|ClassPrivateMethod|ClassDeclaration|ClassExpression|ObjectExpression",t.isHudScopeable=function(e){return r.types.isArrowFunctionExpression(e)||r.types.isBlockStatement(e)||r.types.isCatchClause(e)||r.types.isClassMethod(e)||r.types.isClassPrivateMethod(e)||r.types.isDeclareModule(e)||r.types.isDoExpression(e)||r.types.isDoWhileStatement(e)||r.types.isForInStatement(e)||r.types.isForOfStatement(e)||r.types.isForStatement(e)||r.types.isFunctionDeclaration(e)||r.types.isFunctionExpression(e)||r.types.isIfStatement(e)||r.types.isLabeledStatement(e)||r.types.isObjectMethod(e)||r.types.isProgram(e)||r.types.isStaticBlock(e)||r.types.isSwitchCase(e)||r.types.isTSModuleBlock(e)||r.types.isTryStatement(e)||r.types.isWhileStatement(e)||r.types.isWithStatement(e)||r.types.isClassDeclaration(e)||r.types.isClassExpression(e)||r.types.isObjectExpression(e)||r.types.isSwitchStatement(e)},t.isNamespaceScopeable=function(e){return r.types.isFunction(e)||r.types.isClass(e)||r.types.isObjectExpression(e)}},5913:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getMethodKind=t.getContextualData=t.getContextSymbol=t.getFunctionName=void 0;const i=n(6346),a=s(n(6346)),l=n(9514),c=n(692),u=n(1377),d=n(949),p=n(3830);function f(e,t){return{name:t,sourcemap_location_hints:(0,d.getLocationList)(e)}}function y(e){if(i.types.isIdentifier(e))return{name:e.name,locationHints:e.loc?[{line:e.loc.start.line,column:e.loc.start.column}]:[]};if(i.types.isMemberExpression(e)||i.types.isOptionalMemberExpression(e)){let t;t=i.types.isThisExpression(e.object)?{name:"this",locationHints:(0,d.getLocationList)(e.object)}:y(e.object);const n=y(e.property);return{name:e.computed?t.name+"["+n.name+"]":t.name+"."+n.name,locationHints:[...t.locationHints,...n.locationHints]}}if(i.types.isOptionalCallExpression(e)||i.types.isCallExpression(e))return y(e.callee);if(i.types.isSequenceExpression(e))return(0,p.isHudAwaitSequence)(e)?y((0,p.getHudAwaitSequenceElement)(e)):y(e.expressions[e.expressions.length-1]);if(i.types.isArrayExpression(e))return{name:"[]",locationHints:(0,d.getLocationList)(e)};if(i.types.isObjectExpression(e))return{name:"{}",locationHints:(0,d.getLocationList)(e)};if(i.types.isStringLiteral(e))return{name:`"${e.value}"`,locationHints:(0,d.getLocationList)(e)};throw new l.HudUnsupportedError("Unsupported left side of assignment - "+e.type+"loc - "+JSON.stringify(e.loc))}function m(e){const t=y(e);return{name:t.name,sourcemap_location_hints:t.locationHints}}function g(e){const{node:t}=e;if(e.isExpression())try{return function(e){const{parent:t}=e;if(i.types.isVariableDeclarator(t)&&i.types.isIdentifier(t.id))return f(t,t.id.name);if(i.types.isObjectProperty(t)&&i.types.isIdentifier(t.key))return f(t,t.key.name);if(i.types.isClassProperty(t)&&i.types.isIdentifier(t.key))return f(t,t.key.name);if(i.types.isAssignmentExpression(t))return m(t.left);if(i.types.isAssignmentPattern(t))return m(t.left);throw new l.HudUnsupportedError(`Unsupported parent type - ${t.type} for me ${e.node.type}`)}(e)}catch(e){if(e instanceof l.HudUnsupportedError)return;throw e}u.worker_logger.debug("getContextSymbol; Unsupported node type",{type:t.type})}function h(e){const t=[];return e.arguments.forEach(((e,n)=>{let r,o;i.types.isStringLiteral(e)?(r=c.ArgumentTypes.StringLiteral,o=e.value):i.types.isIdentifier(e)&&(r=c.ArgumentTypes.Identifier,o=e.name),r&&o&&t.push({index:n,type:r,value:o})})),t}t.getFunctionName=function(e){const{node:t}=e;if(i.types.isFunctionDeclaration(t)||i.types.isFunctionExpression(t)){if(i.types.isIdentifier(t.id))return t.id.name}else if(i.types.isClassMethod(t)){if(i.types.isIdentifier(t.key))return t.key.name}else if(i.types.isClassPrivateMethod(t)){if(i.types.isIdentifier(t.key.id))return t.key.id.name}else if(i.types.isObjectMethod(t)&&i.types.isIdentifier(t.key))return t.key.name},t.getContextSymbol=g,t.getContextualData=function(e){let t,n=!1;return(e.isFunctionExpression()||e.isArrowFunctionExpression())&&(t=function(e){const t=e.parentPath;if(t.isCallExpression())for(const[n,r]of t.node.arguments.entries())if(r===e.node){const e=t.node.callee;let r;try{r=m(e)}catch(t){if(!(t instanceof l.HudUnsupportedError))throw t;u.worker_logger.warn("could not get callee symbol recursively",{error:t,type:e.type})}const o=h(t.node);return{callee:{symbol:r,argsCount:t.node.arguments.length,args:o},index:n}}}(e),n=function(e){const t=e.parentPath;return!!t.isCallExpression()&&t.node.callee===e.node}(e)),{symbol:g(e),callback:t,immediatelyInvoked:n}},t.getMethodKind=function(e){if(a.types.isClassMethod(e)||a.types.isObjectMethod(e)||a.types.isClassPrivateMethod(e))return e.kind}},9514:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.UserLogs=t.setFirstError=t.getFirstError=t.isAbortError=t.HudBadLoggerError=t.HudExtensionNextFailedError=t.HudExtensionRegisterError=t.HudExtnensionError=t.HudClientUnauthorizedError=t.HudTimeoutError=t.HudWorkloadCollectorError=t.HudAssert=t.HudUnsupportedError=t.HudEditError=t.HudWorkerError=t.HudClientError=t.HudSessionThrottle=t.HudInitError=t.HudError=void 0;const o=r(n(1019));class s extends Error{code=9e3;name=this.constructor.name;constructor(e){super(e)}}t.HudError=s;class i extends s{code=9001}t.HudInitError=i,t.HudSessionThrottle=class extends i{},t.HudClientError=class extends s{code=9002},t.HudWorkerError=class extends s{code=9003};class a extends s{code=9004}t.HudEditError=a,t.HudUnsupportedError=class extends a{code=9005},t.HudAssert=class extends a{code=9006},t.HudWorkloadCollectorError=class extends s{code=9007},t.HudTimeoutError=class extends s{code=9008},t.HudClientUnauthorizedError=class extends s{code=9009};class l extends s{code=9200}t.HudExtnensionError=l,t.HudExtensionRegisterError=class extends l{code=9201},t.HudExtensionNextFailedError=class extends l{code=9202},t.HudBadLoggerError=class extends s{code=9101},t.isAbortError=function(e){return e instanceof Error&&"AbortError"===e.name};let c=9999;t.getFirstError=function(){return c},t.setFirstError=function(e){e&&9999===c&&(c=e)},t.UserLogs={HudEnableNotSet:e=>({level:"error",moreInfo:!0,message:`Did not load as HUD_ENABLE is ${void 0===e?"undefined":"set to a non-true value"}. Please set HUD_ENABLE=true to run Hud.`}),HudServiceNotSet:()=>({level:"error",errCode:"E1001",moreInfo:!0,message:"Can't load Hud, HUD_SERVICE was not set. Please set service name using the env var HUD_SERVICE."}),HudServiceInvalid:()=>({level:"error",errCode:"E1002",moreInfo:!0,message:"Can't load Hud, HUD_SERVICE value has invalid service name. Please set service name using the env var HUD_SERVICE."}),HudServiceInvalidInit:()=>({level:"error",errCode:"E1003",moreInfo:!0,message:"Can't load Hud, the provided service value is invalid. Please set a valid service name."}),HudApiKeyNotSet:()=>({level:"error",errCode:"E1004",moreInfo:!0,message:"Can't load Hud, HUD_KEY was not set. Please set API key using the env var HUD_KEY."}),HudApiKeyInvalid:()=>({level:"error",errCode:"E1005",moreInfo:!0,message:"Can't load Hud, HUD_KEY value has invalid API key. Please set a valid key in env var HUD_KEY."}),HudApiKeyInvalidInit:()=>({level:"error",errCode:"E1006",moreInfo:!0,message:"Can't load Hud, the provided key value is invalid. Please set a valid key."}),BothApiKeyAndServiceNotSet:()=>({level:"error",errCode:"E1007",moreInfo:!0,message:"Can't load Hud, HUD_KEY and HUD_SERVICE were not set. Please set API key using the env var HUD_KEY and service name using the env var HUD_SERVICE."}),InvalidTag:()=>({level:"warn",errCode:"E1008",moreInfo:!0,message:"HUD_TAGS should be of type Key-Value Object, defaulting to empty tags. Please set valid tags in env var HUD_TAGS."}),TagWithDots:()=>({level:"warn",errCode:"E1009",moreInfo:!0,message:"HUD_TAGS keys can't contain dots; they have been replaced with underscores."}),TagsInvalidJson:()=>({level:"warn",errCode:"E1010",moreInfo:!0,message:"Can't load Hud, HUD_TAGS is not a valid JSON, defaulting to empty tags. Please set valid tags in env var HUD_TAGS."}),ApyKeyDenied:()=>({level:"error",errCode:"E1011",moreInfo:!0,message:"Can't load Hud, the provided key is invalid. Please provide a valid key by either setting the HUD_KEY env var or passing it directly to the init function."}),ShutdownGracefully:e=>({level:"error",errCode:`E${e}`,message:"SDK has initiated a graceful shutdown. Your application remains unaffected"}),UnsupportedNodeVersion:()=>({level:"error",errCode:"E1012",moreInfo:!0,message:"Can't load Hud due to an unsupported node version."}),UnsupportedSyntax:()=>({level:"error",errCode:"E1014",moreInfo:!0,message:"Can't load Hud due to an unsupported syntax version."}),UnsupportedLambdaMemory:()=>({level:"error",errCode:"E1015",moreInfo:!0,message:`Can't load Hud as lambda function memory size is less than ${o.default.lambdaMinimunMemory}MB.`})}},692:(e,t)=>{var n,r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.EntityType=t.ArgumentTypes=t.ParameterTypes=void 0,function(e){e.Identifier="Identifier",e.RestElement="RestElement",e.ArrayPattern="ArrayPattern",e.AssignmentPattern="AssignmentPattern",e.ObjectPattern="ObjectPattern",e.ObjectProperty="ObjectProperty"}(n||(t.ParameterTypes=n={})),function(e){e.StringLiteral="StringLiteral",e.Identifier="Identifier"}(r||(t.ArgumentTypes=r={})),function(e){e.FunctionDeclaration="functionDeclaration",e.FunctionExpression="functionExpression",e.FunctionArrow="functionArrow",e.ClassMethod="classMethod",e.ObjectMethod="objectMethod",e.ClassPrivateMethod="classPrivateMethod",e.ClassDeclaration="classDeclaration",e.ClassExpression="classExpression",e.ObjectExpression="objectExpression",e.Program="program",e.ForLoop="forLoop",e.ForBlock="forBlock",e.ForTest="forTest",e.Block="block",e.While="while",e.DoWhile="doWhile",e.Do="Do",e.WhileTest="whileTest",e.Switch="switch",e.SwitchCase="switchCase",e.Catch="catch",e.With="with",e.If="if",e.IfTest="ifTest",e.IfConsequent="ifConsequent",e.IfAlternate="ifAlternate",e.TryCatch="tryCatch",e.Try="try",e.Finally="finally",e.Other="other",e.File="file"}(o||(t.EntityType=o={}))},1377:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.worker_logger=t.instrument_logger=t.app_logger=t.customer_logger=t.SafeLogger=t.renewFileTransports=t.getSavedLogs=t.getLogPath=t.WorkerPortTransport=void 0;const a=s(n(857)),l=s(n(6928)),c=s(n(5124)),u=s(n(9896)),d=s(n(6982)),p=n(1019),f=i(n(1620)),y=process.env.HUD_DEBUG?p.hudConfig.logger.debug:process.env.HUD_VERBOSE?p.hudConfig.logger.verbose:p.hudConfig.logger.default;class m extends f.default{_messeagesToSend=[];messagesLimit=p.hudConfig.loggerWorkerPortSizeLimit;messageDropCount=0;getMessagesToSend(){if(!this._messeagesToSend.length)return!1;const e=this._messeagesToSend;this.clearMessagesToSend();const t=this.messageDropCount;return this.messageDropCount=0,{logsBuf:this.formatMessagesToSend(e),messageDropCount:t}}clearMessagesToSend(){this._messeagesToSend=[]}formatMessagesToSend(e){return e.map((e=>JSON.stringify(e))).join("\n")}log(e,t){this._messeagesToSend.length>=this.messagesLimit?this.messageDropCount++:this._messeagesToSend.push(e),t()}}t.WorkerPortTransport=m;const g=c.format.combine(c.format.timestamp({format:"HH:mm:ss.SSS"}),c.format.printf((({level:e,message:t,timestamp:n,label:r,...o})=>{try{const s=Object.keys(o).length;let i;if(s)if(1===s){const e=Object.keys(o)[0];i=`${t} ${e}: ${JSON.stringify(o[e],null,2)}`}else i=`${t}\n${JSON.stringify(o,null,2)}`;else i=t;const a=c.format.colorize().colorize(e,e.toUpperCase());return`[${n}]${(r?`(${r})`:"").padEnd(8," ")} ${a}: ${i}`}catch(e){return t}})));function h(e){return c.format.combine(c.format.label({label:e}),c.format.timestamp({format:()=>(new Date).toISOString()}),c.format.json())}function v(e){return{filename:b(),level:y.levels[e],format:h(e),lazy:!1}}function E(){if(p.hudConfig.logDirectory)return p.hudConfig.logDirectory;const e=a.homedir();switch(a.platform()){case"darwin":return l.join(e,"Library","Logs","hud");case"win32":return l.join(e,"AppData","hud","Logs");default:return l.join(e,".hud","logs")}}let _;function b(){return _??=l.join(E(),`${d.randomUUID()}.log`)}t.getLogPath=b,t.getSavedLogs=function(){const e=[];for(const[t,n]of Object.entries(S))for(const t of n.transports)try{if(t instanceof m){const r=t.getMessagesToSend();if(!r)continue;const{logsBuf:o,messageDropCount:s}=r;s&&n.info(`Dropped ${s} messages`),e.push(o)}}catch(e){n.error("Failed to get saved logs",e)}return e},t.renewFileTransports=function(){const e=new Date,t=new Set;for(const[n,r]of Object.entries(S)){const n=[],o=[];for(const s of r.transports)if(s instanceof c.transports.File){s.close&&s.close(),n.push(s),o.push(new c.transports.File({level:s.level,format:s.format,filename:l.join(s.dirname,s.filename),lazy:!1}));const r=l.join(E(),`${d.randomUUID()}-${e.toISOString().replaceAll(":","")}.log`);u.existsSync(l.join(s.dirname,s.filename))&&(u.renameSync(l.join(s.dirname,s.filename),r),t.add(r))}for(const e of n)r.remove(e);for(const e of o)r.add(e)}return t};const S={};class w{name;logger;constructor(e){this.name=e;try{this.logger=function(e){const t=[];y.console&&t.push(new c.transports.Console({format:c.format.combine(c.format.label({label:e}),g)}));let n=!1;try{const n=v(e),r=l.dirname(n.filename);u.mkdirSync(r,{recursive:!0}),u.writeFileSync(n.filename,"",{flag:"w"}),t.push(new c.transports.File(n))}catch{const r=h(e),o=new m({format:r});t.push(o),n=!0}const r=c.createLogger({level:y.levels[e],transports:t});return S[e]=r,n&&r.info("Could not create file transport, fallback succesfully to worker port"),r}(e)}catch(e){this.logger=void 0}}isValid(){return!!this.logger}log(e,t,...n){this.logger&&this.logger.log(e,t,...n)}error(e,...t){this.log("error",e,...t)}warn(e,...t){this.log("warn",e,...t)}info(e,...t){this.log("info",e,...t)}http(e,...t){this.log("http",e,...t)}verbose(e,...t){this.log("verbose",e,...t)}debug(e,...t){this.log("debug",e,...t)}silly(e,...t){this.log("silly",e,...t)}}t.SafeLogger=w,t.customer_logger=c.createLogger({level:p.hudConfig.customerLoggerLevel,transports:[new c.transports.Console({})],format:c.format.printf((({message:e,errCode:t,moreInfo:n})=>{try{let r=`Hud: ${e}`;return n&&(r+=" For more information visit https://docs.hud.io/docs/node-sdk-ie."),void 0!==t&&(r+=` ${t}`),r}catch(t){return e}}))}),t.app_logger=new w("app"),t.instrument_logger=new w("instrument"),t.worker_logger=new w("worker")},5809:e=>{e.exports=require("./config")},6346:e=>{e.exports=require("@babel/core")},4634:e=>{e.exports=require("source-map")},5124:e=>{e.exports=require("winston")},1620:e=>{e.exports=require("winston-transport")},6982:e=>{e.exports=require("crypto")},9896:e=>{e.exports=require("fs")},6760:e=>{e.exports=require("node:path")},857:e=>{e.exports=require("os")},6928:e=>{e.exports=require("path")},8167:e=>{e.exports=require("worker_threads")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0});const t=n(8167),o=n(5600),s=n(1377);async function i(e){try{t.parentPort?.postMessage("eventlooptime");const n=await(0,o.parseDeclarations)(e,t.parentPort);t.parentPort?.postMessage(n)}catch(e){s.worker_logger.error("Error in declaration worker",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}t.parentPort?.once("message",i)}t.isMainThread||(t.parentPort?.setMaxListeners(0),(async()=>{t.parentPort?.once("message",i)})())})(),r})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(global,(()=>(()=>{"use strict";var e={1019:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(n(5809));o(n(5809),t),t.default=s.default},3830:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getHudAwaitSequenceElement=t.isHudAwaitSequence=void 0;const o=n(6346),i=n(9514),s=r(n(1019));t.isHudAwaitSequence=function(e){if(e.expressions.length<2)return!1;const t=e.expressions[e.expressions.length-1];return!!o.types.isIdentifier(t)&&!!t.name.startsWith(s.default.wrapVarPrefix)},t.getHudAwaitSequenceElement=function(e){const t=e.expressions[0];if(!o.types.isAssignmentExpression(t))throw new i.HudUnsupportedError("Expected assignment expression");const{left:n,right:r}=t;if(!o.types.isIdentifier(n)||!n.name.startsWith(s.default.wrapVarPrefix))throw new i.HudUnsupportedError("Expected identifier starting with "+s.default.wrapVarPrefix);return r}},5600:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseDeclarations=t.fixSourceMap=void 0;const a=n(4634),l=n(692),c=i(n(6346)),u=i(n(6982)),d=n(5913),p=s(n(6760)),f=s(n(1019)),y=n(9514),m=n(3645),g=n(7892),h=n(1513),v=n(3118),E=n(949),b=n(1377),_={babelrc:!1,configFile:!1};function S(e){let t;return t="string"==typeof e?JSON.parse(e):e,t.sources=t.sources.map((e=>e.replace(/^webpack:\/\/(?:@[^/]+?[/])?[^/]+\//,""))),t}t.fixSourceMap=S,t.parseDeclarations=async function(e,t=null){const{code:n,map:r,filename:o,hasInputMap:i,bundlerBuildId:s,bundlerBuildIdGenerated:C}=e,w=[],x=n.replace(/_functionId = "(\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b)"/g,(function(e,...t){if(t[0]){const n=e.indexOf(t[0]),r=n+t[0].length;return e.slice(0,n)+"00000000-0000-0000-0000-000000000000"+e.slice(r)}return e})),P=S(r);return await a.SourceMapConsumer.with(P,null,(async e=>{b.worker_logger.debug("Parsing code",{filename:o});const r=await c.parseAsync(n,_);if(b.worker_logger.debug("Parsed code to tree",{filename:o}),null===r)return;const a=[{type:l.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0}],S=new Set;b.worker_logger.debug("Traversing declarations",{filename:o}),t?.postMessage("eventlooptime"),c.traverse(r,{VariableDeclarator:{exit(t){if(!c.types.isIdentifier(t.node.id)||t.node.id.name!==`${f.default.wrapVarPrefix}_functionId`)return;if(!c.types.isStringLiteral(t.node.init))throw new Error("Expected string literal");const n=t.node.init.value,r=t.findParent((e=>e.isFunction()));if(null===r)throw new Error("Function node not found");if(!r.isFunction())throw new Error("Expected function node");if(void 0===r.node.loc||null===r.node.loc||void 0===r.node.start||void 0===r.node.end||null===r.node.start||null===r.node.end)throw new Error("Function node has no location");const l=function(e){const t=u.createHash("sha256");return t.update(e),t.digest("hex")}(x.slice(r.node.start,r.node.end)),y=r.node.async||!1,m=(0,E.getNodeLocation)(r.node,e),g=m.start.source??o,b=(0,h.getEntityType)(r),_=(0,d.getMethodKind)(r.node),S=(0,d.getContextualData)(r);S.symbol&&(S.symbol=(0,E.resolveSymbol)(e,S.symbol)),S.callback?.callee.symbol&&(S.callback.callee.symbol=(0,E.resolveSymbol)(e,S.callback.callee.symbol));const P=(0,v.getParameterInfo)(r,e),{siblingIndex:T,childrenCount:O}=a[a.length-1],H=a.slice(0,-1),I=(0,E.resolveSymbol)(e,{name:(0,d.getFunctionName)(r),sourcemap_location_hints:(0,E.getLocationList)(r.node)}),D={module:p.default.parse(g).name,symbol:I,context:S,file:g,type:b,format:"commonjs",parameters:P,async:y,start_line:m.start.line,end_line:m.end.line,start_column:m.start.column,source_code_hash:l,runtime_function_id:n,bundler_build_id:s,was_bundler_build_id_generated:C,has_input_map:i,scope_chain:H,methodKind:_,siblingIndex:T,childrenCount:O};w.push(D)}},[m.NamespaceScopeAlias]:{enter(t){const{node:n}=t;if(!(0,m.isNamespaceScopeable)(n))return;const r=a[a.length-1];let o=(0,g.getScope)(t);if(!o)return;o=(0,E.resolveScopeSymbols)(e,o);const i=r.childrenCount[o.type]||0,s={...o,childrenCount:{},siblingIndex:i};r.childrenCount[o.type]=i+1,a.push(s),S.add(n)},exit(e){if(S.has(e.node)){const t=a.pop();if(!t||t?.symbol?.name!==(0,g.getScope)(e)?.symbol?.name)throw new y.HudAssert("Scope name is the same as the node name");S.delete(e.node)}}}}),b.worker_logger.debug("Traversed declarations",{filename:o})})),w}},1513:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getEntityName=t.getEntityType=void 0;const r=n(6346),o=n(692),i=n(1377);t.getEntityType=function(e){const{node:t}=e;return r.types.isFunctionDeclaration(t)?o.EntityType.FunctionDeclaration:r.types.isFunctionExpression(t)?o.EntityType.FunctionExpression:r.types.isArrowFunctionExpression(t)?o.EntityType.FunctionArrow:r.types.isObjectMethod(t)?o.EntityType.ObjectMethod:r.types.isStaticBlock(t)||r.types.isClassMethod(t)?o.EntityType.ClassMethod:r.types.isClassPrivateMethod(t)?o.EntityType.ClassPrivateMethod:r.types.isClassDeclaration(t)?o.EntityType.ClassDeclaration:r.types.isClassExpression(t)?o.EntityType.ClassExpression:r.types.isForInStatement(t)||r.types.isForOfStatement(t)||r.types.isForStatement(t)?o.EntityType.ForLoop:r.types.isBlockStatement(t)?function(e){const t=e.parentPath.node;if(!(r.types.isFunctionDeclaration(t)||r.types.isFunctionExpression(t)||r.types.isArrowFunctionExpression(t)||r.types.isClassMethod(t)||r.types.isObjectMethod(t)||r.types.isClassPrivateMethod(t)))if(r.types.isIfStatement(t)){if("consequent"===e.parentKey)return o.EntityType.IfConsequent;if("alternate"===e.parentKey)return o.EntityType.IfAlternate;if("test"===e.parentKey)return o.EntityType.IfTest}else{if(r.types.isBlockStatement(t)||r.types.isProgram(t))return o.EntityType.Block;if(r.types.isTryStatement(t)){if("block"===e.parentKey)return o.EntityType.Try;if("finalizer"===e.parentKey)return o.EntityType.Finally}else{if(r.types.isCatchClause(t))return;if(r.types.isWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(r.types.isDoWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(!(r.types.isForStatement(t)||r.types.isForInStatement(t)||r.types.isForOfStatement(t)))return;if("test"===e.parentKey)return o.EntityType.ForTest;if("body"===e.parentKey)return o.EntityType.ForBlock}}}(e):r.types.isProgram(t)?o.EntityType.Program:r.types.isDoWhileStatement(t)?o.EntityType.DoWhile:r.types.isWhileStatement(t)?o.EntityType.While:r.types.isCatchClause(t)?o.EntityType.Catch:r.types.isObjectExpression(t)?o.EntityType.ObjectExpression:r.types.isWithStatement(t)?o.EntityType.With:r.types.isSwitchStatement(t)?o.EntityType.Switch:r.types.isSwitchCase(t)?o.EntityType.SwitchCase:r.types.isTryStatement(t)?o.EntityType.TryCatch:r.types.isIfStatement(t)?o.EntityType.If:o.EntityType.Other},t.getEntityName=function(e){return r.types.isFunctionDeclaration(e)?r.types.isIdentifier(e.id)?e.id.name:void i.worker_logger.info("Function declaration without an identifier"):r.types.isClassDeclaration(e)?r.types.isIdentifier(e.id)?e.id.name:void i.worker_logger.info("Class declaration without an identifier"):r.types.isFunctionExpression(e)||r.types.isClassExpression(e)?r.types.isIdentifier(e.id)?e.id.name:void 0:r.types.isClassMethod(e)?r.types.isIdentifier(e.key)?e.key.name:void i.worker_logger.info("Class method without an identifier"):r.types.isObjectMethod(e)?r.types.isIdentifier(e.key)?e.key.name:void i.worker_logger.info("Object method without an identifier"):r.types.isClassPrivateMethod(e)?r.types.isIdentifier(e.key.id)?e.key.id.name:void i.worker_logger.info("Class private method without an identifier"):void e.type}},3118:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getParameterInfo=void 0;const s=i(n(6346)),a=n(1377),l=n(692);function c(e,t=0){if(void 0!==e.loc&&null!==e.loc)return{line:e.loc.start.line,column:e.loc.start.column+t}}function u(e){return s.types.isIdentifier(e.argument)?{name:e.argument.name,type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e,e.argument.name.length+3)}:(a.worker_logger.warn("Unsupported rest element",{type:e.argument.type}),{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e)})}function d(e){var t;if(e)switch(e?.type){case"Identifier":return{name:(t=e).name,type:l.ParameterTypes[t.type],sourcemap_location_hint:c(t,t.name.length)};case"AssignmentPattern":return function(e,t,n){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),left:t,right:n}}(e,d(e.left),function(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"BigIntLiteral":case"DecimalLiteral":return{type:e.type,value:e.value};case"RegExpLiteral":return{type:e.type,value:e.pattern}}return{type:e.type}}(e.right));case"ArrayPattern":return function(e,t){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),elements:t}}(e,e.elements.map((e=>d(e))).filter((e=>void 0!==e)));case"RestElement":return u(e);case"ObjectPattern":{const t=[];return e.properties.forEach((e=>{if(s.types.isObjectProperty(e)){const n=s.types.isIdentifier(e.key)&&s.types.isIdentifier(e.value)||s.types.isAssignmentPattern(e.value)?void 0:d(e.key);t.push(function(e,t,n){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),key:t,value:n}}(e,n,d(e.value)))}else s.types.isRestElement(e)&&t.push(u(e))})),function(e,t){return{type:l.ParameterTypes[e.type],sourcemap_location_hint:c(e),properties:t}}(e,t)}default:a.worker_logger.warn("Unsupported parameter type",{type:e.type})}}t.getParameterInfo=function(e,t){return e.node.params.map((e=>{try{return d(e)}catch(e){return}})).filter((e=>void 0!==e)).map((e=>{let n;if(void 0!==e.sourcemap_location_hint){const{name:r,line:o,column:i}=t.originalPositionFor({line:e.sourcemap_location_hint.line,column:e.sourcemap_location_hint.column});null===o||null===i?(a.worker_logger.info("Could not find location for parameter",{type:e.type}),n={line:-1,column:-1}):n={name:r??void 0,line:o,column:i}}return{...e,name:n?.name??e.name,type:e.type,sourcemap_location_hint:n??e.sourcemap_location_hint}}))}},7892:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getScope=void 0;const r=n(1513),o=n(5913),i=n(949);t.getScope=function(e){const t=(0,r.getEntityType)(e);if(t){const n=(0,r.getEntityName)(e.node);return{type:t,context:(0,o.getContextualData)(e),symbol:{name:n,sourcemap_location_hints:(0,i.getLocationList)(e.node)},methodKind:(0,o.getMethodKind)(e.node)}}}},949:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getNodeLocation=t.resolveScopeSymbols=t.resolveSymbol=t.getLocationList=void 0;const r=n(1377);function o(e,t){return{name:t.name,sourcemap_location_hints:t.sourcemap_location_hints.map((t=>{const n=e.originalPositionFor({line:t.line,column:t.column});return null===n.line||null===n.column?{name:t.name,line:-1,column:-1}:{name:n.name??void 0,line:n.line,column:n.column,resolved:!0}}))}}t.getLocationList=function(e){return e.loc?[{line:e.loc.start.line,column:e.loc.start.column}]:[]},t.resolveSymbol=o,t.resolveScopeSymbols=function(e,t){const{context:n}=t,r=n.symbol?o(e,n.symbol):void 0,i=o(e,t.symbol);return{...t,context:{...n,symbol:r},symbol:i}},t.getNodeLocation=function(e,t,n=void 0){const o=e.loc?.start,i=e.loc?.end;if(!o||!i)return r.worker_logger.info("Node without location",{filename:n,type:e.type}),{start:{source:null,line:-1,column:-1},end:{source:null,line:-1,column:-1}};const s=t.originalPositionFor({line:o.line,column:o.column}),a=t.originalPositionFor({line:i.line,column:i.column});return null!==s.line&&null!==s.column&&null!==a.line&&null!==a.column||(r.worker_logger.debug("Could not find location for function",{filename:n,type:e.type,locStart:o,locEnd:i}),s.line=-1,s.column=-1,a.line=-1,a.column=-1),{start:{source:s.source,line:s.line,column:s.column},end:{source:a.source,line:a.line,column:a.column}}}},3645:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNamespaceScopeable=t.isHudScopeable=t.NamespaceScopeAlias=t.ScopableAlias=void 0;const r=n(6346);t.ScopableAlias="ArrowFunctionExpression|BlockStatement|CatchClause|ClassMethod|ClassPrivateMethod|DeclareModule|DoExpression|DoWhileStatement|ForInStatement|ForOfStatement|ForStatement|FunctionDeclaration|FunctionExpression|IfStatement|LabeledStatement|ObjectMethod|StaticBlock|SwitchCase|TSModuleBlock|TryStatement|WhileStatement|WithStatement|ClassDeclaration|ClassExpression|ObjectExpression|SwitchStatement",t.NamespaceScopeAlias="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod|ClassMethod|ClassPrivateMethod|ClassDeclaration|ClassExpression|ObjectExpression",t.isHudScopeable=function(e){return r.types.isArrowFunctionExpression(e)||r.types.isBlockStatement(e)||r.types.isCatchClause(e)||r.types.isClassMethod(e)||r.types.isClassPrivateMethod(e)||r.types.isDeclareModule(e)||r.types.isDoExpression(e)||r.types.isDoWhileStatement(e)||r.types.isForInStatement(e)||r.types.isForOfStatement(e)||r.types.isForStatement(e)||r.types.isFunctionDeclaration(e)||r.types.isFunctionExpression(e)||r.types.isIfStatement(e)||r.types.isLabeledStatement(e)||r.types.isObjectMethod(e)||r.types.isProgram(e)||r.types.isStaticBlock(e)||r.types.isSwitchCase(e)||r.types.isTSModuleBlock(e)||r.types.isTryStatement(e)||r.types.isWhileStatement(e)||r.types.isWithStatement(e)||r.types.isClassDeclaration(e)||r.types.isClassExpression(e)||r.types.isObjectExpression(e)||r.types.isSwitchStatement(e)},t.isNamespaceScopeable=function(e){return r.types.isFunction(e)||r.types.isClass(e)||r.types.isObjectExpression(e)}},5913:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getMethodKind=t.getContextualData=t.getContextSymbol=t.getFunctionName=void 0;const s=n(6346),a=i(n(6346)),l=n(9514),c=n(692),u=n(1377),d=n(949),p=n(3830);function f(e,t){return{name:t,sourcemap_location_hints:(0,d.getLocationList)(e)}}function y(e){if(s.types.isIdentifier(e))return{name:e.name,locationHints:e.loc?[{line:e.loc.start.line,column:e.loc.start.column}]:[]};if(s.types.isMemberExpression(e)||s.types.isOptionalMemberExpression(e)){let t;t=s.types.isThisExpression(e.object)?{name:"this",locationHints:(0,d.getLocationList)(e.object)}:y(e.object);const n=y(e.property);return{name:e.computed?t.name+"["+n.name+"]":t.name+"."+n.name,locationHints:[...t.locationHints,...n.locationHints]}}if(s.types.isOptionalCallExpression(e)||s.types.isCallExpression(e))return y(e.callee);if(s.types.isSequenceExpression(e))return(0,p.isHudAwaitSequence)(e)?y((0,p.getHudAwaitSequenceElement)(e)):y(e.expressions[e.expressions.length-1]);if(s.types.isArrayExpression(e))return{name:"[]",locationHints:(0,d.getLocationList)(e)};if(s.types.isObjectExpression(e))return{name:"{}",locationHints:(0,d.getLocationList)(e)};if(s.types.isStringLiteral(e))return{name:`"${e.value}"`,locationHints:(0,d.getLocationList)(e)};throw new l.HudUnsupportedError("Unsupported left side of assignment - "+e.type+"loc - "+JSON.stringify(e.loc))}function m(e){const t=y(e);return{name:t.name,sourcemap_location_hints:t.locationHints}}function g(e){const{node:t}=e;if(e.isExpression())try{return function(e){const{parent:t}=e;if(s.types.isVariableDeclarator(t)&&s.types.isIdentifier(t.id))return f(t,t.id.name);if(s.types.isObjectProperty(t)&&s.types.isIdentifier(t.key))return f(t,t.key.name);if(s.types.isClassProperty(t)&&s.types.isIdentifier(t.key))return f(t,t.key.name);if(s.types.isAssignmentExpression(t))return m(t.left);if(s.types.isAssignmentPattern(t))return m(t.left);throw new l.HudUnsupportedError(`Unsupported parent type - ${t.type} for me ${e.node.type}`)}(e)}catch(e){if(e instanceof l.HudUnsupportedError)return;throw e}u.worker_logger.debug("getContextSymbol; Unsupported node type",{type:t.type})}function h(e){const t=[];return e.arguments.forEach(((e,n)=>{let r,o;s.types.isStringLiteral(e)?(r=c.ArgumentTypes.StringLiteral,o=e.value):s.types.isIdentifier(e)&&(r=c.ArgumentTypes.Identifier,o=e.name),r&&o&&t.push({index:n,type:r,value:o})})),t}t.getFunctionName=function(e){const{node:t}=e;if(s.types.isFunctionDeclaration(t)||s.types.isFunctionExpression(t)){if(s.types.isIdentifier(t.id))return t.id.name}else if(s.types.isClassMethod(t)){if(s.types.isIdentifier(t.key))return t.key.name}else if(s.types.isClassPrivateMethod(t)){if(s.types.isIdentifier(t.key.id))return t.key.id.name}else if(s.types.isObjectMethod(t)&&s.types.isIdentifier(t.key))return t.key.name},t.getContextSymbol=g,t.getContextualData=function(e){let t,n=!1;return(e.isFunctionExpression()||e.isArrowFunctionExpression())&&(t=function(e){const t=e.parentPath;if(t.isCallExpression())for(const[n,r]of t.node.arguments.entries())if(r===e.node){const e=t.node.callee;let r;try{r=m(e)}catch(t){if(!(t instanceof l.HudUnsupportedError))throw t;u.worker_logger.warn("could not get callee symbol recursively",{error:t,type:e.type})}const o=h(t.node);return{callee:{symbol:r,argsCount:t.node.arguments.length,args:o},index:n}}}(e),n=function(e){const t=e.parentPath;return!!t.isCallExpression()&&t.node.callee===e.node}(e)),{symbol:g(e),callback:t,immediatelyInvoked:n}},t.getMethodKind=function(e){if(a.types.isClassMethod(e)||a.types.isObjectMethod(e)||a.types.isClassPrivateMethod(e))return e.kind}},9514:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.UserLogs=t.setFirstError=t.getFirstError=t.isAbortError=t.HudBadLoggerError=t.HudExtensionNextFailedError=t.HudExtensionRegisterError=t.HudExtnensionError=t.HudClientUnauthorizedError=t.HudTimeoutError=t.HudWorkloadCollectorError=t.HudAssert=t.HudUnsupportedError=t.HudEditError=t.HudWorkerError=t.HudClientError=t.HudSessionThrottle=t.HudInitError=t.HudError=void 0;const o=r(n(1019));class i extends Error{code=9e3;name=this.constructor.name;constructor(e){super(e)}}t.HudError=i;class s extends i{code=9001}t.HudInitError=s,t.HudSessionThrottle=class extends s{},t.HudClientError=class extends i{code=9002},t.HudWorkerError=class extends i{code=9003};class a extends i{code=9004}t.HudEditError=a,t.HudUnsupportedError=class extends a{code=9005},t.HudAssert=class extends a{code=9006},t.HudWorkloadCollectorError=class extends i{code=9007},t.HudTimeoutError=class extends i{code=9008},t.HudClientUnauthorizedError=class extends i{code=9009};class l extends i{code=9200}t.HudExtnensionError=l,t.HudExtensionRegisterError=class extends l{code=9201},t.HudExtensionNextFailedError=class extends l{code=9202},t.HudBadLoggerError=class extends i{code=9101},t.isAbortError=function(e){return e instanceof Error&&"AbortError"===e.name};let c=9999;t.getFirstError=function(){return c},t.setFirstError=function(e){e&&9999===c&&(c=e)},t.UserLogs={HudEnableNotSet:e=>({level:"error",moreInfo:!0,message:`Did not load as HUD_ENABLE is ${void 0===e?"undefined":"set to a non-true value"}. Please set HUD_ENABLE=true to run Hud.`}),HudServiceNotSet:()=>({level:"error",errCode:"E1001",moreInfo:!0,message:"Can't load Hud, HUD_SERVICE was not set. Please set service name using the environment variable HUD_SERVICE."}),HudServiceInvalid:()=>({level:"error",errCode:"E1002",moreInfo:!0,message:"Can't load Hud, HUD_SERVICE value has invalid service name. Please set service name using the environment variable HUD_SERVICE."}),HudApiKeyNotSet:()=>({level:"error",errCode:"E1004",moreInfo:!0,message:"Can't load Hud, HUD_KEY was not set. Please set API key using the environment variable HUD_KEY."}),HudApiKeyInvalid:()=>({level:"error",errCode:"E1005",moreInfo:!0,message:"Can't load Hud, HUD_KEY value has invalid API key. Please set a valid key in environment variable HUD_KEY."}),BothApiKeyAndServiceNotSet:()=>({level:"error",errCode:"E1007",moreInfo:!0,message:"Can't load Hud, HUD_KEY and HUD_SERVICE were not set. Please set API key using the environment variable HUD_KEY and service name using the environment variable HUD_SERVICE."}),InvalidTag:()=>({level:"warn",errCode:"E1008",moreInfo:!0,message:"HUD_TAGS should be of type Key-Value Object, defaulting to empty tags. Please set valid tags in environment variable HUD_TAGS."}),TagWithDots:()=>({level:"warn",errCode:"E1009",moreInfo:!0,message:"HUD_TAGS keys can't contain dots; they have been replaced with underscores."}),TagsInvalidJson:()=>({level:"warn",errCode:"E1010",moreInfo:!0,message:"Can't load Hud, HUD_TAGS is not a valid JSON, defaulting to empty tags. Please set valid tags in environment variable HUD_TAGS."}),ApyKeyDenied:e=>({level:"error",errCode:"E1011",moreInfo:!0,message:`Can't load Hud, the provided key is invalid. Please provide a valid HUD_KEY in your ${{ENV:"environment variable",FILE:"file",INIT:"init function"}[e]}.`}),ShutdownGracefully:e=>({level:"error",errCode:`E${e}`,message:"SDK has initiated a graceful shutdown. Your application remains unaffected"}),UnsupportedNodeVersion:()=>({level:"error",errCode:"E1012",moreInfo:!0,message:"Can't load Hud due to an unsupported node version."}),UnsupportedSyntax:()=>({level:"error",errCode:"E1014",moreInfo:!0,message:"Can't load Hud due to an unsupported syntax version."}),UnsupportedLambdaMemory:()=>({level:"error",errCode:"E1015",moreInfo:!0,message:`Can't load Hud as lambda function memory size is less than ${o.default.lambdaMinimunMemory}MB.`}),JSONErrorInUserConfig:(e,t)=>({level:"error",errCode:"E1016",moreInfo:!0,message:`Can't load Hud, the config file contains an invalid JSON. Please set a valid json in Hud's config file, Path: ${e}`+(t?`, Error: ${t}.`:".")}),ZodErrorInUserConfig:(e,t)=>({level:"error",errCode:"E1017",moreInfo:!0,message:`Can't load Hud, the config file contains an invalid value for field: ${t}. Please set a valid value for ${t} in the config file ${e}.`}),ConfigInaccessible:e=>({level:"error",errCode:"E1018",moreInfo:!0,message:`Can't load Hud, the config file is inaccessible. Please make sure your node application has read permissions to the Hud config file, ${e}.`})}},692:(e,t)=>{var n,r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.EntityType=t.ArgumentTypes=t.ParameterTypes=void 0,function(e){e.Identifier="Identifier",e.RestElement="RestElement",e.ArrayPattern="ArrayPattern",e.AssignmentPattern="AssignmentPattern",e.ObjectPattern="ObjectPattern",e.ObjectProperty="ObjectProperty"}(n||(t.ParameterTypes=n={})),function(e){e.StringLiteral="StringLiteral",e.Identifier="Identifier"}(r||(t.ArgumentTypes=r={})),function(e){e.FunctionDeclaration="functionDeclaration",e.FunctionExpression="functionExpression",e.FunctionArrow="functionArrow",e.ClassMethod="classMethod",e.ObjectMethod="objectMethod",e.ClassPrivateMethod="classPrivateMethod",e.ClassDeclaration="classDeclaration",e.ClassExpression="classExpression",e.ObjectExpression="objectExpression",e.Program="program",e.ForLoop="forLoop",e.ForBlock="forBlock",e.ForTest="forTest",e.Block="block",e.While="while",e.DoWhile="doWhile",e.Do="Do",e.WhileTest="whileTest",e.Switch="switch",e.SwitchCase="switchCase",e.Catch="catch",e.With="with",e.If="if",e.IfTest="ifTest",e.IfConsequent="ifConsequent",e.IfAlternate="ifAlternate",e.TryCatch="tryCatch",e.Try="try",e.Finally="finally",e.Other="other",e.File="file"}(o||(t.EntityType=o={}))},1377:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.worker_logger=t.instrument_logger=t.app_logger=t.customer_logger=t.SafeLogger=t.renewFileTransports=t.getSavedLogs=t.getLogPath=t.WorkerPortTransport=void 0;const a=i(n(857)),l=i(n(6928)),c=i(n(5124)),u=i(n(9896)),d=i(n(6982)),p=n(1019),f=s(n(1620)),y=process.env.HUD_DEBUG?p.hudConfig.logger.debug:process.env.HUD_VERBOSE?p.hudConfig.logger.verbose:p.hudConfig.logger.default;class m extends f.default{_messeagesToSend=[];messagesLimit=p.hudConfig.loggerWorkerPortSizeLimit;messageDropCount=0;getMessagesToSend(){if(!this._messeagesToSend.length)return!1;const e=this._messeagesToSend;this.clearMessagesToSend();const t=this.messageDropCount;return this.messageDropCount=0,{logsBuf:this.formatMessagesToSend(e),messageDropCount:t}}clearMessagesToSend(){this._messeagesToSend=[]}formatMessagesToSend(e){return e.map((e=>JSON.stringify(e))).join("\n")}log(e,t){this._messeagesToSend.length>=this.messagesLimit?this.messageDropCount++:this._messeagesToSend.push(e),t()}}t.WorkerPortTransport=m;const g=c.format.combine(c.format.timestamp({format:"HH:mm:ss.SSS"}),c.format.printf((({level:e,message:t,timestamp:n,label:r,...o})=>{try{const i=Object.keys(o).length;let s;if(i)if(1===i){const e=Object.keys(o)[0];s=`${t} ${e}: ${JSON.stringify(o[e],null,2)}`}else s=`${t}\n${JSON.stringify(o,null,2)}`;else s=t;const a=c.format.colorize().colorize(e,e.toUpperCase());return`[${n}]${(r?`(${r})`:"").padEnd(8," ")} ${a}: ${s}`}catch(e){return t}})));function h(e){return c.format.combine(c.format.label({label:e}),c.format.timestamp({format:()=>(new Date).toISOString()}),c.format.json())}function v(e){return{filename:_(),level:y.levels[e],format:h(e),lazy:!1}}function E(){if(p.hudConfig.logDirectory)return p.hudConfig.logDirectory;const e=a.homedir();switch(a.platform()){case"darwin":return l.join(e,"Library","Logs","hud");case"win32":return l.join(e,"AppData","hud","Logs");default:return l.join(e,".hud","logs")}}let b;function _(){return b??=l.join(E(),`${d.randomUUID()}.log`)}t.getLogPath=_,t.getSavedLogs=function(){const e=[];for(const[t,n]of Object.entries(S))for(const t of n.transports)try{if(t instanceof m){const r=t.getMessagesToSend();if(!r)continue;const{logsBuf:o,messageDropCount:i}=r;i&&n.info(`Dropped ${i} messages`),e.push(o)}}catch(e){n.error("Failed to get saved logs",e)}return e},t.renewFileTransports=function(){const e=new Date,t=new Set;for(const[n,r]of Object.entries(S)){const n=[],o=[];for(const i of r.transports)if(i instanceof c.transports.File){i.close&&i.close(),n.push(i),o.push(new c.transports.File({level:i.level,format:i.format,filename:l.join(i.dirname,i.filename),lazy:!1}));const r=l.join(E(),`${d.randomUUID()}-${e.toISOString().replaceAll(":","")}.log`);u.existsSync(l.join(i.dirname,i.filename))&&(u.renameSync(l.join(i.dirname,i.filename),r),t.add(r))}for(const e of n)r.remove(e);for(const e of o)r.add(e)}return t};const S={};class C{name;logger;constructor(e){this.name=e;try{this.logger=function(e){const t=[];y.console&&t.push(new c.transports.Console({format:c.format.combine(c.format.label({label:e}),g)}));let n=!1;try{const n=v(e),r=l.dirname(n.filename);u.mkdirSync(r,{recursive:!0}),u.writeFileSync(n.filename,"",{flag:"w"}),t.push(new c.transports.File(n))}catch{const r=h(e),o=new m({format:r});t.push(o),n=!0}const r=c.createLogger({level:y.levels[e],transports:t});return S[e]=r,n&&r.info("Could not create file transport, fallback succesfully to worker port"),r}(e)}catch(e){this.logger=void 0}}isValid(){return!!this.logger}log(e,t,...n){this.logger&&this.logger.log(e,t,...n)}error(e,...t){this.log("error",e,...t)}warn(e,...t){this.log("warn",e,...t)}info(e,...t){this.log("info",e,...t)}http(e,...t){this.log("http",e,...t)}verbose(e,...t){this.log("verbose",e,...t)}debug(e,...t){this.log("debug",e,...t)}silly(e,...t){this.log("silly",e,...t)}}t.SafeLogger=C,t.customer_logger=c.createLogger({level:p.hudConfig.customerLoggerLevel,transports:[new c.transports.Console({})],format:c.format.printf((({message:e,errCode:t,moreInfo:n})=>{try{let r=`Hud: ${e}`;return n&&(r+=" For more information visit https://docs.hud.io/docs/node-sdk-ie."),void 0!==t&&(r+=` ${t}`),r}catch(t){return e}}))}),t.app_logger=new C("app"),t.instrument_logger=new C("instrument"),t.worker_logger=new C("worker")},5809:e=>{e.exports=require("./config")},6346:e=>{e.exports=require("@babel/core")},4634:e=>{e.exports=require("source-map")},5124:e=>{e.exports=require("winston")},1620:e=>{e.exports=require("winston-transport")},6982:e=>{e.exports=require("crypto")},9896:e=>{e.exports=require("fs")},6760:e=>{e.exports=require("node:path")},857:e=>{e.exports=require("os")},6928:e=>{e.exports=require("path")},8167:e=>{e.exports=require("worker_threads")}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0});const t=n(8167),o=n(5600),i=n(1377);async function s(e){try{t.parentPort?.postMessage("eventlooptime");const n=await(0,o.parseDeclarations)(e,t.parentPort);t.parentPort?.postMessage(n)}catch(e){i.worker_logger.error("Error in declaration worker",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}t.parentPort?.once("message",s)}t.isMainThread||(t.parentPort?.setMaxListeners(0),(async()=>{t.parentPort?.once("message",s)})())})(),r})()));
2
2
  //# sourceMappingURL=declarationWorker.js.map