dd-trace 5.93.0 → 5.95.0

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.
Files changed (59) hide show
  1. package/LICENSE-3rdparty.csv +46 -44
  2. package/index.d.ts +182 -13
  3. package/package.json +14 -10
  4. package/packages/datadog-instrumentations/src/anthropic.js +1 -1
  5. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +23 -0
  6. package/packages/datadog-instrumentations/src/helpers/rewriter/{orchestrion/compiler.js → compiler.js} +4 -13
  7. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +16 -2
  8. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +2 -2
  9. package/packages/datadog-instrumentations/src/helpers/rewriter/{orchestrion/transforms.js → transforms.js} +3 -89
  10. package/packages/datadog-instrumentations/src/jest.js +118 -32
  11. package/packages/datadog-instrumentations/src/mocha/main.js +6 -0
  12. package/packages/datadog-instrumentations/src/mocha/utils.js +89 -5
  13. package/packages/datadog-instrumentations/src/playwright.js +10 -0
  14. package/packages/datadog-instrumentations/src/vitest.js +119 -0
  15. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +12 -0
  16. package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -4
  17. package/packages/datadog-plugin-jest/src/index.js +6 -0
  18. package/packages/datadog-plugin-mocha/src/index.js +11 -0
  19. package/packages/datadog-plugin-playwright/src/index.js +9 -0
  20. package/packages/datadog-plugin-vitest/src/index.js +9 -0
  21. package/packages/datadog-webpack/index.js +187 -0
  22. package/packages/datadog-webpack/src/loader.js +27 -0
  23. package/packages/datadog-webpack/src/log.js +32 -0
  24. package/packages/dd-trace/src/azure_metadata.js +15 -15
  25. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +176 -33
  26. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +10 -21
  27. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +76 -1
  28. package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +259 -0
  29. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +56 -0
  30. package/packages/dd-trace/src/config/config-base.d.ts +7 -0
  31. package/packages/dd-trace/src/config/config-base.js +5 -0
  32. package/packages/dd-trace/src/config/config-types.d.ts +78 -0
  33. package/packages/dd-trace/src/config/generated-config-types.d.ts +582 -0
  34. package/packages/dd-trace/src/config/supported-configurations.json +7 -0
  35. package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
  36. package/packages/dd-trace/src/llmobs/constants/text.js +1 -1
  37. package/packages/dd-trace/src/llmobs/constants/writers.js +1 -1
  38. package/packages/dd-trace/src/llmobs/plugins/anthropic.js +11 -2
  39. package/packages/dd-trace/src/llmobs/plugins/openai/index.js +4 -1
  40. package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
  41. package/packages/dd-trace/src/opentracing/span.js +5 -0
  42. package/packages/dd-trace/src/plugin_manager.js +10 -7
  43. package/packages/dd-trace/src/plugins/util/test.js +76 -0
  44. package/packages/dd-trace/src/priority_sampler.js +1 -1
  45. package/packages/dd-trace/src/profiling/profilers/wall.js +35 -28
  46. package/packages/dd-trace/src/rate_limiter.js +2 -1
  47. package/packages/dd-trace/src/tagger.js +31 -35
  48. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +28 -0
  49. package/vendor/dist/@apm-js-collab/code-transformer/index.js +133 -0
  50. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  51. package/vendor/dist/@opentelemetry/resources/index.js +1 -1
  52. package/vendor/dist/esquery/index.js +1 -1
  53. package/vendor/dist/meriyah/index.js +1 -1
  54. package/webpack.js +3 -0
  55. package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/index.js +0 -43
  56. package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/matcher.js +0 -49
  57. package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/transformer.js +0 -121
  58. package/vendor/dist/astring/LICENSE +0 -19
  59. package/vendor/dist/astring/index.js +0 -1
package/webpack.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict'
2
+
3
+ module.exports = require('./packages/datadog-webpack/index.js')
@@ -1,43 +0,0 @@
1
- 'use strict'
2
-
3
- /*
4
- This folder is basically a JavaScript version of Orchestrion-JS. The goal is
5
- not to replace Orchestrion-JS, but rather to make it easier and faster to write
6
- new integrations in the short-term, especially as many changes to the rewriter
7
- will be needed as all the patterns we need have not been identified yet. This
8
- will avoid the back and forth of having to make Rust changes to an external
9
- library for every integration change or addition that requires something new.
10
-
11
- In the meantime, we'll work concurrently on a change to Orchestrion-JS that
12
- adds an "arbitrary transform" or "plugin" system that can be used from
13
- JavaScript, in order to enable quick iteration while still using Orchestrion-JS.
14
- Once that's done we'll use that, so that we can remove this JS approach and
15
- return to using Orchestrion-JS.
16
-
17
- The long term goal is to backport any additional features we add to the JS
18
- rewriter (or using the plugin system in Orchestrion-JS once we're using that)
19
- to Orchestrion-JS once we're confident that the implementation is fairly
20
- complete and has all features we need.
21
-
22
- Here is a list of the additions and changes in this rewriter compared to
23
- Orchestrion-JS that will need to be backported:
24
-
25
- (NOTE: Please keep this list up-to-date whenever new features are added)
26
-
27
- - Supports an `astQuery` field to filter AST nodes with an esquery query. This
28
- is mostly meant to be used when experimenting or if what needs to be queried
29
- is not a function. We'll see over time if something like this is needed to be
30
- backported or if it can be replaced by simpler queries.
31
- - Supports replacing methods of child class instances in the base constructor.
32
- - Supports tracing iterator (sync/async) returning functions (sync/async).
33
- */
34
-
35
- /* eslint-disable camelcase */
36
-
37
- const { InstrumentationMatcher } = require('./matcher')
38
-
39
- function create (configs, dc_module) {
40
- return new InstrumentationMatcher(configs, dc_module)
41
- }
42
-
43
- module.exports = { create }
@@ -1,49 +0,0 @@
1
- 'use strict'
2
-
3
- /* eslint-disable camelcase */
4
-
5
- const semifies = require('../../../../../../vendor/dist/semifies')
6
- const { Transformer } = require('./transformer')
7
-
8
- // TODO: addTransform
9
-
10
- class InstrumentationMatcher {
11
- #configs = []
12
- #dc_module = null
13
- #transformers = {}
14
-
15
- constructor (configs, dc_module) {
16
- this.#configs = configs
17
- this.#dc_module = dc_module || 'diagnostics_channel'
18
- }
19
-
20
- free () {
21
- this.#transformers = {}
22
- }
23
-
24
- getTransformer (module_name, version, file_path) {
25
- const id = `${module_name}/${file_path}@${version}`
26
-
27
- if (this.#transformers[id]) return this.#transformers[id]
28
-
29
- const configs = this.#configs.filter(({ module: { name, filePath, versionRange } }) =>
30
- name === module_name &&
31
- filePath === file_path &&
32
- semifies(version, versionRange)
33
- )
34
-
35
- if (configs.length === 0) return
36
-
37
- this.#transformers[id] = new Transformer(
38
- module_name,
39
- version,
40
- file_path,
41
- configs,
42
- this.#dc_module
43
- )
44
-
45
- return this.#transformers[id]
46
- }
47
- }
48
-
49
- module.exports = { InstrumentationMatcher }
@@ -1,121 +0,0 @@
1
- 'use strict'
2
-
3
- /* eslint-disable camelcase */
4
-
5
- const { generate, parse, traverse } = require('./compiler')
6
- const transforms = require('./transforms')
7
-
8
- let SourceMapConsumer
9
- let SourceMapGenerator
10
-
11
- class Transformer {
12
- #module_name = null
13
- #file_path = null
14
- #configs = []
15
- #dc_module = null
16
-
17
- // TODO: module_name false for user module
18
- constructor (module_name, _version, file_path, configs, dc_module) {
19
- this.#module_name = module_name
20
- this.#file_path = file_path
21
- this.#configs = configs
22
- this.#dc_module = dc_module
23
- }
24
-
25
- free () {
26
- // Freeing is not needed for a JavaScript implementation.
27
- }
28
-
29
- transform (code, module_type, sourcemap) {
30
- if (!code) return { code }
31
-
32
- const sourceType = module_type === 'esm' ? 'module' : 'script'
33
-
34
- let ast
35
-
36
- for (const config of this.#configs) {
37
- const { astQuery, functionQuery = {} } = config
38
-
39
- ast ??= parse(code.toString(), { range: true, sourceType })
40
-
41
- const query = astQuery || this.#fromFunctionQuery(functionQuery)
42
- const state = { ...config, dcModule: this.#dc_module, sourceType, functionQuery }
43
-
44
- state.operator = this.#getOperator(state)
45
-
46
- traverse(ast, query, (...args) => this.#visit(state, ...args))
47
- }
48
-
49
- if (ast) {
50
- SourceMapConsumer ??= require('../../../../../../vendor/dist/@datadog/source-map').SourceMapConsumer
51
- SourceMapGenerator ??= require('../../../../../../vendor/dist/@datadog/source-map').SourceMapGenerator
52
-
53
- const file = `${this.#module_name}/${this.#file_path}`
54
- const sourceMapInput = sourcemap ? new SourceMapConsumer(sourcemap) : { file }
55
- const sourceMap = new SourceMapGenerator(sourceMapInput)
56
- const code = generate(ast, { sourceMap })
57
- const map = sourceMap.toString()
58
-
59
- return { code, map }
60
- }
61
-
62
- return { code }
63
- }
64
-
65
- #visit (state, ...args) {
66
- const transform = transforms[state.operator]
67
- const { index } = state.functionQuery
68
-
69
- if (index !== undefined) {
70
- state.functionIndex = ++state.functionIndex || 0
71
-
72
- if (index !== state.functionIndex) return
73
- }
74
-
75
- transform(state, ...args)
76
- }
77
-
78
- #getOperator ({ functionQuery: { kind } }) {
79
- switch (kind) {
80
- case 'Async': return 'tracePromise'
81
- case 'AsyncIterator': return 'traceAsyncIterator'
82
- case 'Callback': return 'traceCallback'
83
- case 'Iterator': return 'traceIterator'
84
- case 'Sync': return 'traceSync'
85
- }
86
- }
87
-
88
- #fromFunctionQuery (functionQuery) {
89
- const { functionName, expressionName, className } = functionQuery
90
- const method = functionQuery.methodName || functionQuery.privateMethodName
91
- const type = functionQuery.privateMethodName ? 'PrivateIdentifier' : 'Identifier'
92
- const queries = []
93
-
94
- if (className) {
95
- queries.push(
96
- `[id.name="${className}"]`,
97
- `[id.name="${className}"] > ClassExpression`,
98
- `[id.name="${className}"] > ClassBody > [key.name="${method}"][key.type=${type}] > [async]`,
99
- `[id.name="${className}"] > ClassExpression > ClassBody > [key.name="${method}"][key.type=${type}] > [async]`
100
- )
101
- } else if (method) {
102
- queries.push(
103
- `ClassBody > [key.name="${method}"][key.type=${type}] > [async]`,
104
- `Property[key.name="${method}"][key.type=${type}] > [async]`
105
- )
106
- }
107
-
108
- if (functionName) {
109
- queries.push(`FunctionDeclaration[id.name="${functionName}"][async]`)
110
- } else if (expressionName) {
111
- queries.push(
112
- `FunctionExpression[id.name="${expressionName}"][async]`,
113
- `ArrowFunctionExpression[id.name="${expressionName}"][async]`
114
- )
115
- }
116
-
117
- return queries.join(', ')
118
- }
119
- }
120
-
121
- module.exports = { Transformer }
@@ -1,19 +0,0 @@
1
- Copyright (c) 2015, David Bonnet <david@bonnet.cc>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
@@ -1 +0,0 @@
1
- (()=>{"use strict";let e,t,i,r,n,s;var o={};o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};o.r(l),o.d(l,{EXPRESSIONS_PRECEDENCE:()=>w,GENERATOR:()=>u,NEEDS_PARENTHESES:()=>m,baseGenerator:()=>h,generate:()=>generate});let{stringify:a}=JSON;if(!String.prototype.repeat)throw Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");let p={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},m=17,w={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:17,ClassExpression:17,FunctionExpression:17,ObjectExpression:17,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function formatSequence(e,t){let{generator:i}=e;if(e.write("("),null!=t&&t.length>0){i[t[0].type](t[0],e);let{length:r}=t;for(let n=1;n<r;n++){let r=t[n];e.write(", "),i[r.type](r,e)}}e.write(")")}function expressionNeedsParenthesis(e,t,i,r){let n=e.expressionsPrecedence[t.type];if(n===m)return!0;let s=e.expressionsPrecedence[i.type];return n!==s?!r&&15===n&&14===s&&"**"===i.operator||n<s:(13===n||14===n)&&("**"===t.operator&&"**"===i.operator?!r:13===n&&13===s&&("??"===t.operator||"??"===i.operator)||(r?p[t.operator]<=p[i.operator]:p[t.operator]<p[i.operator]))}function formatExpression(e,t,i,r){let{generator:n}=e;expressionNeedsParenthesis(e,t,i,r)?(e.write("("),n[t.type](t,e),e.write(")")):n[t.type](t,e)}function reindent(e,t,i,r){let n=t.split("\n"),s=n.length-1;if(e.write(n[0].trim()),s>0){e.write(r);for(let t=1;t<s;t++)e.write(i+n[t].trim()+r);e.write(i+n[s].trim())}}function formatComments(e,t,i,r){let{length:n}=t;for(let s=0;s<n;s++){let n=t[s];e.write(i),"L"===n.type[0]?e.write("// "+n.value.trim()+"\n",n):(e.write("/*"),reindent(e,n.value,i,r),e.write("*/"+r))}}function hasCallExpression(e){let t=e;for(;null!=t;){let{type:e}=t;if("C"===e[0]&&"a"===e[1])return!0;if("M"!==e[0]||"e"!==e[1]||"m"!==e[2])return!1;t=t.object}}function formatVariableDeclaration(e,t){let{generator:i}=e,{declarations:r}=t;e.write(t.kind+" ");let{length:n}=r;if(n>0){i.VariableDeclarator(r[0],e);for(let t=1;t<n;t++)e.write(", "),i.VariableDeclarator(r[t],e)}}let u={Program(e,t){let i=t.indent.repeat(t.indentLevel),{lineEnd:r,writeComments:n}=t;n&&null!=e.comments&&formatComments(t,e.comments,i,r);let s=e.body,{length:o}=s;for(let e=0;e<o;e++){let o=s[e];n&&null!=o.comments&&formatComments(t,o.comments,i,r),t.write(i),this[o.type](o,t),t.write(r)}n&&null!=e.trailingComments&&formatComments(t,e.trailingComments,i,r)},BlockStatement:s=function(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:n}=t,s=i+t.indent;t.write("{");let o=e.body;if(null!=o&&o.length>0){t.write(r),n&&null!=e.comments&&formatComments(t,e.comments,s,r);let{length:l}=o;for(let e=0;e<l;e++){let i=o[e];n&&null!=i.comments&&formatComments(t,i.comments,s,r),t.write(s),this[i.type](i,t),t.write(r)}t.write(i)}else n&&null!=e.comments&&(t.write(r),formatComments(t,e.comments,s,r),t.write(i));n&&null!=e.trailingComments&&formatComments(t,e.trailingComments,s,r),t.write("}"),t.indentLevel--},ClassBody:s,StaticBlock(e,t){t.write("static "),this.BlockStatement(e,t)},EmptyStatement(e,t){t.write(";")},ExpressionStatement(e,t){let i=t.expressionsPrecedence[e.expression.type];i===m||3===i&&"O"===e.expression.left.type[0]?(t.write("("),this[e.expression.type](e.expression,t),t.write(")")):this[e.expression.type](e.expression,t),t.write(";")},IfStatement(e,t){t.write("if ("),this[e.test.type](e.test,t),t.write(") "),this[e.consequent.type](e.consequent,t),null!=e.alternate&&(t.write(" else "),this[e.alternate.type](e.alternate,t))},LabeledStatement(e,t){this[e.label.type](e.label,t),t.write(": "),this[e.body.type](e.body,t)},BreakStatement(e,t){t.write("break"),null!=e.label&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},ContinueStatement(e,t){t.write("continue"),null!=e.label&&(t.write(" "),this[e.label.type](e.label,t)),t.write(";")},WithStatement(e,t){t.write("with ("),this[e.object.type](e.object,t),t.write(") "),this[e.body.type](e.body,t)},SwitchStatement(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:n}=t;t.indentLevel++;let s=i+t.indent,o=s+t.indent;t.write("switch ("),this[e.discriminant.type](e.discriminant,t),t.write(") {"+r);let{cases:l}=e,{length:a}=l;for(let e=0;e<a;e++){let i=l[e];n&&null!=i.comments&&formatComments(t,i.comments,s,r),i.test?(t.write(s+"case "),this[i.test.type](i.test,t),t.write(":"+r)):t.write(s+"default:"+r);let{consequent:a}=i,{length:p}=a;for(let e=0;e<p;e++){let i=a[e];n&&null!=i.comments&&formatComments(t,i.comments,o,r),t.write(o),this[i.type](i,t),t.write(r)}}t.indentLevel-=2,t.write(i+"}")},ReturnStatement(e,t){t.write("return"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t)),t.write(";")},ThrowStatement(e,t){t.write("throw "),this[e.argument.type](e.argument,t),t.write(";")},TryStatement(e,t){if(t.write("try "),this[e.block.type](e.block,t),e.handler){let{handler:i}=e;null==i.param?t.write(" catch "):(t.write(" catch ("),this[i.param.type](i.param,t),t.write(") ")),this[i.body.type](i.body,t)}e.finalizer&&(t.write(" finally "),this[e.finalizer.type](e.finalizer,t))},WhileStatement(e,t){t.write("while ("),this[e.test.type](e.test,t),t.write(") "),this[e.body.type](e.body,t)},DoWhileStatement(e,t){t.write("do "),this[e.body.type](e.body,t),t.write(" while ("),this[e.test.type](e.test,t),t.write(");")},ForStatement(e,t){if(t.write("for ("),null!=e.init){let{init:i}=e;"V"===i.type[0]?formatVariableDeclaration(t,i):this[i.type](i,t)}t.write("; "),e.test&&this[e.test.type](e.test,t),t.write("; "),e.update&&this[e.update.type](e.update,t),t.write(") "),this[e.body.type](e.body,t)},ForInStatement:e=function(e,t){t.write(`for ${e.await?"await ":""}(`);let{left:i}=e;"V"===i.type[0]?formatVariableDeclaration(t,i):this[i.type](i,t),t.write("I"===e.type[3]?" in ":" of "),this[e.right.type](e.right,t),t.write(") "),this[e.body.type](e.body,t)},ForOfStatement:e,DebuggerStatement(e,t){t.write("debugger;",e)},FunctionDeclaration:t=function(e,t){t.write((e.async?"async ":"")+(e.generator?"function* ":"function ")+(e.id?e.id.name:""),e),formatSequence(t,e.params),t.write(" "),this[e.body.type](e.body,t)},FunctionExpression:t,VariableDeclaration(e,t){formatVariableDeclaration(t,e),t.write(";")},VariableDeclarator(e,t){this[e.id.type](e.id,t),null!=e.init&&(t.write(" = "),this[e.init.type](e.init,t))},ClassDeclaration(e,t){if(t.write("class "+(e.id?`${e.id.name} `:""),e),e.superClass){t.write("extends ");let{superClass:i}=e,{type:r}=i,n=t.expressionsPrecedence[r];("C"!==r[0]||"l"!==r[1]||"E"!==r[5])&&(n===m||n<t.expressionsPrecedence.ClassExpression)?(t.write("("),this[e.superClass.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ")}this.ClassBody(e.body,t)},ImportDeclaration(e,t){t.write("import ");let{specifiers:i,attributes:r}=e,{length:n}=i,s=0;if(n>0){for(;s<n;){s>0&&t.write(", ");let e=i[s],r=e.type[6];if("D"===r)t.write(e.local.name,e),s++;else if("N"===r)t.write("* as "+e.local.name,e),s++;else break}if(s<n){for(t.write("{");;){let e=i[s],{name:r}=e.imported;if(t.write(r,e),r!==e.local.name&&t.write(" as "+e.local.name),++s<n)t.write(", ");else break}t.write("}")}t.write(" from ")}if(this.Literal(e.source,t),r&&r.length>0){t.write(" with { ");for(let e=0;e<r.length;e++)this.ImportAttribute(r[e],t),e<r.length-1&&t.write(", ");t.write(" }")}t.write(";")},ImportAttribute(e,t){this.Identifier(e.key,t),t.write(": "),this.Literal(e.value,t)},ImportExpression(e,t){t.write("import("),this[e.source.type](e.source,t),t.write(")")},ExportDefaultDeclaration(e,t){t.write("export default "),this[e.declaration.type](e.declaration,t),null!=t.expressionsPrecedence[e.declaration.type]&&"F"!==e.declaration.type[0]&&t.write(";")},ExportNamedDeclaration(e,t){if(t.write("export "),e.declaration)this[e.declaration.type](e.declaration,t);else{t.write("{");let{specifiers:i}=e,{length:r}=i;if(r>0)for(let e=0;;){let n=i[e],{name:s}=n.local;if(t.write(s,n),s!==n.exported.name&&t.write(" as "+n.exported.name),++e<r)t.write(", ");else break}if(t.write("}"),e.source&&(t.write(" from "),this.Literal(e.source,t)),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let i=0;i<e.attributes.length;i++)this.ImportAttribute(e.attributes[i],t),i<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")}},ExportAllDeclaration(e,t){if(null!=e.exported?t.write("export * as "+e.exported.name+" from "):t.write("export * from "),this.Literal(e.source,t),e.attributes&&e.attributes.length>0){t.write(" with { ");for(let i=0;i<e.attributes.length;i++)this.ImportAttribute(e.attributes[i],t),i<e.attributes.length-1&&t.write(", ");t.write(" }")}t.write(";")},MethodDefinition(e,t){e.static&&t.write("static ");let i=e.kind[0];("g"===i||"s"===i)&&t.write(e.kind+" "),e.value.async&&t.write("async "),e.value.generator&&t.write("*"),e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),formatSequence(t,e.value.params),t.write(" "),this[e.value.body.type](e.value.body,t)},ClassExpression(e,t){this.ClassDeclaration(e,t)},ArrowFunctionExpression(e,t){t.write(e.async?"async ":"",e);let{params:i}=e;null!=i&&(1===i.length&&"I"===i[0].type[0]?t.write(i[0].name,i[0]):formatSequence(t,e.params)),t.write(" => "),"O"===e.body.type[0]?(t.write("("),this.ObjectExpression(e.body,t),t.write(")")):this[e.body.type](e.body,t)},ThisExpression(e,t){t.write("this",e)},Super(e,t){t.write("super",e)},RestElement:i=function(e,t){t.write("..."),this[e.argument.type](e.argument,t)},SpreadElement:i,YieldExpression(e,t){t.write(e.delegate?"yield*":"yield"),e.argument&&(t.write(" "),this[e.argument.type](e.argument,t))},AwaitExpression(e,t){t.write("await ",e),formatExpression(t,e.argument,e)},TemplateLiteral(e,t){let{quasis:i,expressions:r}=e;t.write("`");let{length:n}=r;for(let e=0;e<n;e++){let n=r[e],s=i[e];t.write(s.value.raw,s),t.write("${"),this[n.type](n,t),t.write("}")}let s=i[i.length-1];t.write(s.value.raw,s),t.write("`")},TemplateElement(e,t){t.write(e.value.raw,e)},TaggedTemplateExpression(e,t){formatExpression(t,e.tag,e),this[e.quasi.type](e.quasi,t)},ArrayExpression:n=function(e,t){if(t.write("["),e.elements.length>0){let{elements:i}=e,{length:r}=i;for(let e=0;;){let n=i[e];if(null!=n&&this[n.type](n,t),++e<r)t.write(", ");else{null==n&&t.write(", ");break}}}t.write("]")},ArrayPattern:n,ObjectExpression(e,t){let i=t.indent.repeat(t.indentLevel++),{lineEnd:r,writeComments:n}=t,s=i+t.indent;if(t.write("{"),e.properties.length>0){t.write(r),n&&null!=e.comments&&formatComments(t,e.comments,s,r);let o=","+r,{properties:l}=e,{length:a}=l;for(let e=0;;){let i=l[e];if(n&&null!=i.comments&&formatComments(t,i.comments,s,r),t.write(s),this[i.type](i,t),++e<a)t.write(o);else break}t.write(r),n&&null!=e.trailingComments&&formatComments(t,e.trailingComments,s,r),t.write(i+"}")}else n?null!=e.comments?(t.write(r),formatComments(t,e.comments,s,r),null!=e.trailingComments&&formatComments(t,e.trailingComments,s,r),t.write(i+"}")):null!=e.trailingComments?(t.write(r),formatComments(t,e.trailingComments,s,r),t.write(i+"}")):t.write("}"):t.write("}");t.indentLevel--},Property(e,t){e.method||"i"!==e.kind[0]?this.MethodDefinition(e,t):(e.shorthand||(e.computed?(t.write("["),this[e.key.type](e.key,t),t.write("]")):this[e.key.type](e.key,t),t.write(": ")),this[e.value.type](e.value,t))},PropertyDefinition(e,t){if(e.static&&t.write("static "),e.computed&&t.write("["),this[e.key.type](e.key,t),e.computed&&t.write("]"),null==e.value){"F"!==e.key.type[0]&&t.write(";");return}t.write(" = "),this[e.value.type](e.value,t),t.write(";")},ObjectPattern(e,t){if(t.write("{"),e.properties.length>0){let{properties:i}=e,{length:r}=i;for(let e=0;;)if(this[i[e].type](i[e],t),++e<r)t.write(", ");else break}t.write("}")},SequenceExpression(e,t){formatSequence(t,e.expressions)},UnaryExpression(e,t){if(e.prefix){let{operator:i,argument:r,argument:{type:n}}=e;t.write(i);let s=expressionNeedsParenthesis(t,r,e);!s&&(i.length>1||"U"===n[0]&&("n"===n[1]||"p"===n[1])&&r.prefix&&r.operator[0]===i&&("+"===i||"-"===i))&&t.write(" "),s?(t.write(i.length>1?" (":"("),this[n](r,t),t.write(")")):this[n](r,t)}else this[e.argument.type](e.argument,t),t.write(e.operator)},UpdateExpression(e,t){e.prefix?(t.write(e.operator),this[e.argument.type](e.argument,t)):(this[e.argument.type](e.argument,t),t.write(e.operator))},AssignmentExpression(e,t){this[e.left.type](e.left,t),t.write(" "+e.operator+" "),this[e.right.type](e.right,t)},AssignmentPattern(e,t){this[e.left.type](e.left,t),t.write(" = "),this[e.right.type](e.right,t)},BinaryExpression:r=function(e,t){let i="in"===e.operator;i&&t.write("("),formatExpression(t,e.left,e,!1),t.write(" "+e.operator+" "),formatExpression(t,e.right,e,!0),i&&t.write(")")},LogicalExpression:r,ConditionalExpression(e,t){let{test:i}=e,r=t.expressionsPrecedence[i.type];r===m||r<=t.expressionsPrecedence.ConditionalExpression?(t.write("("),this[i.type](i,t),t.write(")")):this[i.type](i,t),t.write(" ? "),this[e.consequent.type](e.consequent,t),t.write(" : "),this[e.alternate.type](e.alternate,t)},NewExpression(e,t){t.write("new ");let i=t.expressionsPrecedence[e.callee.type];i===m||i<t.expressionsPrecedence.CallExpression||hasCallExpression(e.callee)?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),formatSequence(t,e.arguments)},CallExpression(e,t){let i=t.expressionsPrecedence[e.callee.type];i===m||i<t.expressionsPrecedence.CallExpression?(t.write("("),this[e.callee.type](e.callee,t),t.write(")")):this[e.callee.type](e.callee,t),e.optional&&t.write("?."),formatSequence(t,e.arguments)},ChainExpression(e,t){this[e.expression.type](e.expression,t)},MemberExpression(e,t){let i=t.expressionsPrecedence[e.object.type];i===m||i<t.expressionsPrecedence.MemberExpression?(t.write("("),this[e.object.type](e.object,t),t.write(")")):this[e.object.type](e.object,t),e.computed?(e.optional&&t.write("?."),t.write("["),this[e.property.type](e.property,t),t.write("]")):(e.optional?t.write("?."):t.write("."),this[e.property.type](e.property,t))},MetaProperty(e,t){t.write(e.meta.name+"."+e.property.name,e)},Identifier(e,t){t.write(e.name,e)},PrivateIdentifier(e,t){t.write(`#${e.name}`,e)},Literal(e,t){null!=e.raw?t.write(e.raw,e):null!=e.regex?this.RegExpLiteral(e,t):null!=e.bigint?t.write(e.bigint+"n",e):t.write(a(e.value),e)},RegExpLiteral(e,t){let{regex:i}=e;t.write(`/${i.pattern}/${i.flags}`,e)}},c={},h=u;let State=class State{constructor(e){const t=null==e?c:e;this.output="",null!=t.output?(this.output=t.output,this.write=this.writeToStream):this.output="",this.generator=null!=t.generator?t.generator:u,this.expressionsPrecedence=null!=t.expressionsPrecedence?t.expressionsPrecedence:w,this.indent=null!=t.indent?t.indent:" ",this.lineEnd=null!=t.lineEnd?t.lineEnd:"\n",this.indentLevel=null!=t.startingIndentLevel?t.startingIndentLevel:0,this.writeComments=!!t.comments&&t.comments,null!=t.sourceMap&&(this.write=null==t.output?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=t.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split("\n").length-1,this.mapping={original:null,generated:this,name:void 0,source:t.sourceMap.file||t.sourceMap._file})}write(e){this.output+=e}writeToStream(e){this.output.write(e)}writeAndMap(e,t){this.output+=e,this.map(e,t)}writeToStreamAndMap(e,t){this.output.write(e),this.map(e,t)}map(e,t){if(null!=t){let{type:i}=t;if("L"===i[0]&&"n"===i[2]){this.column=0,this.line++;return}if(null!=t.loc){let{mapping:e}=this;e.original=t.loc.start,e.name=t.name,this.sourceMap.addMapping(e)}if("T"===i[0]&&"E"===i[8]||"L"===i[0]&&"i"===i[1]&&"string"==typeof t.value){let{length:t}=e,{column:i,line:r}=this;for(let n=0;n<t;n++)"\n"===e[n]?(i=0,r++):i++;this.column=i,this.line=r;return}}let{length:i}=e,{lineEnd:r}=this;i>0&&(this.lineEndSize>0&&(1===r.length?e[i-1]===r:e.endsWith(r))?(this.line+=this.lineEndSize,this.column=0):this.column+=i)}toString(){return this.output}};function generate(e,t){let i=new State(t);return i.generator[e.type](e,i),i.output}module.exports=l})();