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AAQ,CACN,KAAM,aACN,KAAM,GAER,SAAU,CACR,KAAM,aACN,KAAM,IAGV,MAAO,CACL,KAAM,mBACN,UAAU,EACV,OAAQ,CACN,KAAM,aACN,KAAM,GAER,SAAU,CACR,KAAM,aACN,KAAM,KAMhB,CAEA,MAAM,eAAiB,CACrB,SAAS,EACT,mBAAmB,EACnB,sBAAuB,UACvB,qBAAsB,cAGxB,QAAQ,SAAW,SAAU,EAAQ,EAAU,gBAC7C,EAAU,OAAO,OAAO,CAAC,EAAG,eAAgB,GAC5C,MAAM,EAAM,QAAQ,YAAY,EAAQ,CAAE,cAAe,EAAQ,UAKjE,MAAO,CACL,oBALgB,cAAc,EAAK,GAMnC,kBALwB,EAAQ,kBAC9B,0BAA0B,EAAK,QAC/B,EAKN","file":"/npm/gas-entry-generator@3.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gas-entry-generator@3.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nconst esprima = require(\"esprima-next\");\nconst estraverse = require(\"estraverse\");\nconst escodegen = require(\"escodegen\");\n\nfunction createBaseAST() {\n  const ast = {};\n  ast.type = \"Program\";\n  ast.body = [];\n  return ast;\n}\n\nfunction createStubFunctionASTNode(functionName, leadingComments, params) {\n  const node = {\n    type: \"FunctionDeclaration\",\n    id: {\n      type: \"Identifier\",\n      name: functionName,\n    },\n    params: [],\n    defaults: [],\n    body: {\n      type: \"BlockStatement\",\n      body: [],\n    },\n    generator: false,\n    expression: false,\n  };\n  if (leadingComments) {\n    node.leadingComments = leadingComments;\n  }\n  if (params) {\n    node.params = params;\n  }\n  return node;\n}\n\nclass EntryPointFunctions {\n  constructor() {\n    this.stubs = new Map();\n    this.functionNames = [];\n  }\n\n  add(functionName, params, comments) {\n    let index = this.functionNames.indexOf(functionName);\n    if (index === -1) {\n      index = this.functionNames.push(functionName) - 1;\n    }\n    this.stubs.set(\n      index,\n      createStubFunctionASTNode(functionName, comments, params)\n    );\n  }\n\n  getEntryPointFunctions() {\n    const entryPointFunctions = [];\n    for (let index = 0; index < this.functionNames.length; index++) {\n      entryPointFunctions.push(this.stubs.get(index));\n    }\n    return entryPointFunctions;\n  }\n}\n\nclass GlobalAssignments {\n  constructor({\n    exportsIdentifierName = \"exports\",\n    globalIdentifierName = \"globalThis\",\n  }) {\n    this.stubs = [];\n    this.functionNames = new Set();\n    this.exportsIdentifierName = exportsIdentifierName;\n    this.globalIdentifierName = globalIdentifierName;\n  }\n\n  add(functionName) {\n    if (this.functionNames.has(functionName)) {\n      return;\n    }\n    this.functionNames.add(functionName);\n    this.stubs.push(\n      createGlobalAssignmentASTNode(\n        functionName,\n        this.exportsIdentifierName,\n        this.globalIdentifierName\n      )\n    );\n  }\n\n  getGlobalAssignments() {\n    return this.stubs;\n  }\n}\n\nfunction _generateStubs(ast, options) {\n  const { autoGlobalExports, globalIdentifierName } = options;\n  const entryPointFunctions = new EntryPointFunctions();\n  estraverse.traverse(ast, {\n    leave: function (node) {\n      if (\n        node.type === \"ExpressionStatement\" &&\n        isGlobalAssignmentExpression(node.expression, globalIdentifierName)\n      ) {\n        const functionName = node.expression.left.property.name;\n        entryPointFunctions.add(\n          functionName,\n          node.expression.right.params,\n          node.leadingComments\n        );\n      } else if (\n        node.type === \"ExpressionStatement\" &&\n        node.expression.type === \"SequenceExpression\"\n      ) {\n        node.expression.expressions.forEach(function (expression) {\n          if (isGlobalAssignmentExpression(expression, globalIdentifierName)) {\n            const functionName = expression.left.property.name;\n            entryPointFunctions.add(\n              functionName,\n              expression.right.params,\n              expression.leadingComments\n                ? expression.leadingComments\n                : node.leadingComments\n            );\n          }\n        });\n      }\n      if (autoGlobalExports) {\n        if (\n          node.type === \"ExpressionStatement\" &&\n          isNamedExportsAssignmentExpression(node.expression)\n        ) {\n          const functionName = node.expression.left.property.name;\n          entryPointFunctions.add(\n            functionName,\n            node.expression.right.params,\n            node.leadingComments\n          );\n        } else if (\n          node.type === \"ExpressionStatement\" &&\n          node.expression.type === \"SequenceExpression\"\n        ) {\n          node.expression.expressions.forEach(function (expression) {\n            if (isNamedExportsAssignmentExpression(expression)) {\n              const functionName = expression.left.property.name;\n              entryPointFunctions.add(\n                functionName,\n                expression.right.params,\n                expression.leadingComments\n                  ? expression.leadingComments\n                  : node.leadingComments\n              );\n            }\n          });\n        } else if (node.type === \"ExportNamedDeclaration\") {\n          const functionNames = node.specifiers.map(\n            (specifier) => specifier.local.name\n          );\n          functionNames.forEach((functionName) =>\n            entryPointFunctions.add(functionName)\n          );\n          // ex: export function foo() {};\n          if (\n            node.declaration &&\n            node.declaration.type === \"FunctionDeclaration\"\n          ) {\n            entryPointFunctions.add(node.declaration.id.name);\n          }\n        }\n      }\n    },\n  });\n\n  return entryPointFunctions.getEntryPointFunctions();\n}\n\nfunction isGlobalAssignmentExpression(node, globalIdentifierName) {\n  return (\n    node.type === \"AssignmentExpression\" &&\n    node.operator === \"=\" &&\n    node.left.type === \"MemberExpression\" &&\n    node.left.object.type === \"Identifier\" &&\n    node.left.object.name === globalIdentifierName\n  );\n}\n\nfunction isNamedExportsAssignmentExpression(node) {\n  return (\n    node.type === \"AssignmentExpression\" &&\n    node.operator === \"=\" &&\n    node.left.type === \"MemberExpression\" &&\n    node.left.object.type === \"Identifier\" &&\n    node.left.object.name === \"exports\" &&\n    node.left.property.type === \"Identifier\" &&\n    node.left.property.name !== \"default\"\n  );\n}\n\nfunction generateStubs(ast, options) {\n  const baseAST = createBaseAST();\n  const stubs = _generateStubs(ast, options);\n  baseAST.body.push(...stubs);\n  return escodegen.generate(baseAST, { comment: !!options.comment });\n}\n\nfunction generateGlobalAssignments(ast, options) {\n  const globalAssignments = new GlobalAssignments(options);\n  estraverse.traverse(ast, {\n    leave: (node) => {\n      if (\n        node.type === \"ExpressionStatement\" &&\n        isNamedExportsAssignmentExpression(node.expression)\n      ) {\n        const functionName = node.expression.left.property.name;\n        globalAssignments.add(functionName);\n      } else if (\n        node.type === \"ExpressionStatement\" &&\n        node.expression.type === \"SequenceExpression\"\n      ) {\n        node.expression.expressions.forEach(function (expression) {\n          if (isNamedExportsAssignmentExpression(expression)) {\n            const functionName = expression.left.property.name;\n            globalAssignments.add(functionName);\n          }\n        });\n      } else if (node.type === \"ExportNamedDeclaration\") {\n        // ex: export { foo } from './foo.js';\n        const functionNames = node.specifiers.map(\n          (specifier) => specifier.local.name\n        );\n        functionNames.forEach((functionName) =>\n          globalAssignments.add(functionName)\n        );\n        // ex: export function foo() {};\n        if (\n          node.declaration &&\n          node.declaration.type === \"FunctionDeclaration\"\n        ) {\n          globalAssignments.add(node.declaration.id.name);\n        }\n      }\n    },\n  });\n  const baseAST = createBaseAST();\n  baseAST.body.push(...globalAssignments.getGlobalAssignments());\n  return escodegen.generate(baseAST);\n}\n\nfunction createGlobalAssignmentASTNode(\n  functionName,\n  exportsIdentifierName,\n  globalIdentifierName\n) {\n  const node = {\n    type: \"ExpressionStatement\",\n    expression: {\n      type: \"AssignmentExpression\",\n      operator: \"=\",\n      left: {\n        type: \"MemberExpression\",\n        computed: false,\n        object: {\n          type: \"Identifier\",\n          name: globalIdentifierName,\n        },\n        property: {\n          type: \"Identifier\",\n          name: functionName,\n        },\n      },\n      right: {\n        type: \"MemberExpression\",\n        computed: false,\n        object: {\n          type: \"Identifier\",\n          name: exportsIdentifierName,\n        },\n        property: {\n          type: \"Identifier\",\n          name: functionName,\n        },\n      },\n    },\n  };\n  return node;\n}\n\nconst defaultOptions = {\n  comment: false,\n  autoGlobalExports: false,\n  exportsIdentifierName: \"exports\",\n  globalIdentifierName: \"globalThis\",\n};\n\nexports.generate = function (source, options = defaultOptions) {\n  options = Object.assign({}, defaultOptions, options);\n  const ast = esprima.parseModule(source, { attachComment: options.comment });\n  const functions = generateStubs(ast, options);\n  const globalAssignments = options.autoGlobalExports\n    ? generateGlobalAssignments(ast, options)\n    : undefined;\n  return {\n    entryPointFunctions: functions,\n    globalAssignments,\n  };\n};\n"]}